<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>David Turner &#187; Arena</title>
	<atom:link href="http://www.david-turner.net/category/arena/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.david-turner.net</link>
	<description>...Developing Software for the Church</description>
	<lastBuildDate>Thu, 11 Mar 2010 16:01:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Alerts</title>
		<link>http://www.david-turner.net/2010/03/alerts/</link>
		<comments>http://www.david-turner.net/2010/03/alerts/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 15:57:25 +0000</pubDate>
		<dc:creator>David Turner</dc:creator>
				<category><![CDATA[Arena]]></category>
		<category><![CDATA[CCV]]></category>

		<guid isPermaLink="false">http://www.david-turner.net/2010/03/alerts/</guid>
		<description><![CDATA[As Arena Administrators, we like to know of problems before our users do.&#160; To that end we created an “Alerts” module.&#160; We’ve placed this module on our Arena home page and secured it so that only Arena Administrators can see it.&#160; It tests for various conditions and when problems occur, it will display an “alert.”&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>As Arena Administrators, we like to know of problems before our users do.&#160; To that end we created an “Alerts” module.&#160; We’ve placed this module on our Arena home page and secured it so that only Arena Administrators can see it.&#160; It tests for various conditions and when problems occur, it will display an “alert.”&#160; In this example, you can see that we have a large number of communications that have not gone out.</p>
<p><a href="http://www.david-turner.net/wp-content/uploads/2010/03/image.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.david-turner.net/wp-content/uploads/2010/03/image_thumb.png" width="516" height="315" /></a> </p>
<p>This module uses a custom table to store the alert messages and a few custom stored procedures.&#160; We store the alert messages so that they don’t need to be calculated on every view of the module.&#160; The module has a configurable cache duration and alerts are only processed if that cache duration has expired (or user clicks the “refresh” link). </p>
<p>Currently our procedure to process alerts is only checking for queued emails and for serving reminders being created, but it could be modified to check for anything that is important to you as an administrator.</p>
<p>You can download the user control and SQL script <a href="http://www.ccvonline.com/downloads/community/alerts.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2010/03/alerts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>eRA</title>
		<link>http://www.david-turner.net/2009/10/era/</link>
		<comments>http://www.david-turner.net/2009/10/era/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 18:21:08 +0000</pubDate>
		<dc:creator>David Turner</dc:creator>
				<category><![CDATA[Arena]]></category>

		<guid isPermaLink="false">http://www.david-turner.net/2009/10/era/</guid>
		<description><![CDATA[During RefreshCache, Jon showed a lot of the stuff we’ve been doing with eRA (estimated regular attendees).&#160; Here is how we capture that data…
dtmt_estimated_regular_attendees
This is the table that stores all the data.&#160; To track the eRA wins and losses, we need to know at any point in time, whether a family is considered an eRA. [...]]]></description>
			<content:encoded><![CDATA[<p>During <a href="http://www.refreshcache.com">RefreshCache</a>, Jon showed a lot of the stuff we’ve been doing with eRA (estimated regular attendees).&#160; Here is how we capture that data…</p>
<h3>dtmt_estimated_regular_attendees</h3>
<p>This is the table that stores all the data.&#160; To track the eRA wins and losses, we need to know at any point in time, whether a family is considered an eRA. </p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">TABLE</span> [dbo].[dtmt_estimated_regular_attendees](</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    [weekend_date] [datetime] <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    [family_id] [<span style="color: #0000ff">int</span>] <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    [times_attended_last_16_weeks] [<span style="color: #0000ff">int</span>] <span style="color: #0000ff">NULL</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    [first_attended] [datetime] <span style="color: #0000ff">NULL</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    [last_attended] [datetime] <span style="color: #0000ff">NULL</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    [times_gave_last_6_weeks] [<span style="color: #0000ff">int</span>] <span style="color: #0000ff">NULL</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    [times_gave_total] [<span style="color: #0000ff">int</span>] <span style="color: #0000ff">NULL</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    [last_gave] [datetime] <span style="color: #0000ff">NULL</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    [regular_attendee] [<span style="color: #0000ff">bit</span>] <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    [regular_attendee_c] [<span style="color: #0000ff">bit</span>] <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    [regular_attendee_g] [<span style="color: #0000ff">bit</span>] <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"> <span style="color: #0000ff">CONSTRAINT</span> [PK_dtmt_estimated_regular_attendees] <span style="color: #0000ff">PRIMARY</span> <span style="color: #0000ff">KEY</span> <span style="color: #0000ff">CLUSTERED</span> </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">(</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    [weekend_date] <span style="color: #0000ff">ASC</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    [family_id] <span style="color: #0000ff">ASC</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">)<span style="color: #0000ff">WITH</span> (PAD_INDEX  = <span style="color: #0000ff">OFF</span>, STATISTICS_NORECOMPUTE  = <span style="color: #0000ff">OFF</span>, IGNORE_DUP_KEY = <span style="color: #0000ff">OFF</span>, ALLOW_ROW_LOCKS  = <span style="color: #0000ff">ON</span>, ALLOW_PAGE_LOCKS  = <span style="color: #0000ff">ON</span>) <span style="color: #0000ff">ON</span> [<span style="color: #0000ff">PRIMARY</span>]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">) <span style="color: #0000ff">ON</span> [<span style="color: #0000ff">PRIMARY</span>]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">GO</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">ALTER</span> <span style="color: #0000ff">TABLE</span> [dbo].[dtmt_estimated_regular_attendees] <span style="color: #0000ff">ADD</span>  <span style="color: #0000ff">CONSTRAINT</span> [DF_cust_ccv_estimated_regular_attendees_regular_attendee]  <span style="color: #0000ff">DEFAULT</span> ((0)) <span style="color: #0000ff">FOR</span> [regular_attendee]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">GO</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">ALTER</span> <span style="color: #0000ff">TABLE</span> [dbo].[dtmt_estimated_regular_attendees] <span style="color: #0000ff">ADD</span>  <span style="color: #0000ff">CONSTRAINT</span> [DF_dtmt_estimated_regular_attendees_regular_attendee_c]  <span style="color: #0000ff">DEFAULT</span> ((0)) <span style="color: #0000ff">FOR</span> [regular_attendee_c]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">GO</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">ALTER</span> <span style="color: #0000ff">TABLE</span> [dbo].[dtmt_estimated_regular_attendees] <span style="color: #0000ff">ADD</span>  <span style="color: #0000ff">CONSTRAINT</span> [DF_dtmt_estimated_regular_attendees_regular_attendee_g]  <span style="color: #0000ff">DEFAULT</span> ((0)) <span style="color: #0000ff">FOR</span> [regular_attendee_g]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">GO</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></div>
</div>
<h3>&#160;</h3>
<h3>cust_ccv_sp_dtmt_loadEstimatedRegularAttendees</h3>
<p>Every day we run this SQL proc (configured as an agent job) to load the most recent weekends numbers.&#160; When looking at attendance, we include attendance from children’s check-in that occurs at the same time that an adult service takes place (which is why we exclude high school attendance).</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">ALTER</span> <span style="color: #0000ff">PROC</span> [dbo].[cust_ccv_sp_dtmt_loadEstimatedRegularAttendees] </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">@CurrentDate datetime</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">AS</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">BEGIN</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">--<span style="color: #0000ff">DECLARE</span> @CurrentDate datetime</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">--<span style="color: #0000ff">SET</span> @CurrentDate = GETDATE()</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">DECLARE</span> @SaturdayDate DATETIME</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">SET</span> @SaturdayDate = dbo.util_funct_saturday(@CurrentDate)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">DELETE</span> dtmt_estimated_regular_attendees</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">WHERE</span> weekend_date = @SaturdayDate;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ----<span style="color: #008000">/****************************************************************************</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">        </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">    ----    ATTENDANCE      </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000"></span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">    ----    Calculate the number of times each family has attended in the last 16</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">    ----    weeks and when they last attended based on children's attendance records.</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">        </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">    ----*****************************************************************************/</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    INSERT <span style="color: #0000ff">INTO</span> dtmt_estimated_regular_attendees (</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        weekend_date,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        family_id,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        times_attended_last_16_weeks)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">SELECT</span> </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        @SaturdayDate,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        fm.family_id,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">COUNT</span>(<span style="color: #0000ff">DISTINCT</span> O.service_time)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">FROM</span> core_occurrence_attendance OA</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_v_occurrence_service O <span style="color: #0000ff">ON</span> O.occurrence_id = OA.occurrence_id</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_family_member FM <span style="color: #0000ff">ON</span> FM.person_id = OA.person_id</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">WHERE</span> O.is_service = 1</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">AND</span> OA.attended = 1</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">AND</span> O.occurrence_type_id &lt;&gt; 6 <span style="color: #008000">-- High School</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">AND</span> service_time &lt;= @SaturdayDate</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">AND</span> service_time &gt;= DATEADD(week, -15, @SaturdayDate)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">GROUP</span> <span style="color: #0000ff">BY</span> fm.family_id</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #008000">/****************************************************************************</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">        </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">        GIVING      </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000"></span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">        Calculate the number of times each family has given in the last 6 weeks,</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">        total times they've given and when the last time they gave was</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">        </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">    *****************************************************************************/</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">DECLARE</span> @FamilyContributionCount <span style="color: #0000ff">TABLE</span> (</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        family_id [<span style="color: #0000ff">int</span>] <span style="color: #0000ff">not</span> <span style="color: #0000ff">null</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        total_count [<span style="color: #0000ff">int</span>] <span style="color: #0000ff">null</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        recent_count [<span style="color: #0000ff">int</span>] <span style="color: #0000ff">null</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        last_gave [datetime] <span style="color: #0000ff">null</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    );</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">with</span> cte</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">as</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    (</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">SELECT</span> </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            weekend_date,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            family_id,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> weekend_date &gt;= DATEADD(week, -5, @SaturdayDate) </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> recent</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">FROM</span> cust_ccv_v_family_giving_weekend</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">WHERE</span> weekend_date &lt;= @SaturdayDate</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">AND</span> weekend_date &gt; <span style="color: #006080">'1/1/2005'</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #008000">-- Insert Total Count into temporary table    </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    INSERT <span style="color: #0000ff">INTO</span> @FamilyContributionCount </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">SELECT</span> </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        family_id,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">COUNT</span>(*),</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">SUM</span>(recent),</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">MAX</span>(weekend_date)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">FROM</span> cte</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">GROUP</span> <span style="color: #0000ff">BY</span> family_id</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    --<span style="color: #0000ff">Update</span> Existing Records</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">UPDATE</span> RA</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">SET</span> </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        times_gave_last_6_weeks = FCC.recent_count,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        times_gave_total = FCC.total_count,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        last_gave = FCC.last_gave</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">FROM</span> @FamilyContributionCount FCC</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> dtmt_estimated_regular_attendees RA</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">ON</span> RA.family_id = FCC.family_id</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">AND</span> RA.weekend_date = @SaturdayDate</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #008000">-- Create New Records</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    INSERT <span style="color: #0000ff">INTO</span> dtmt_estimated_regular_attendees (</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        weekend_date,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        family_id,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        times_gave_last_6_weeks,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        times_gave_total,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        last_gave)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">SELECT</span> </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        @SaturdayDate,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        FCC.family_id,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        FCC.recent_count,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        FCC.total_count,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        FCC.last_gave</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">FROM</span> @FamilyContributionCount FCC</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">LEFT</span> <span style="color: #0000ff">OUTER</span> <span style="color: #0000ff">JOIN</span> dtmt_estimated_regular_attendees RA</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">ON</span> RA.family_id = FCC.family_id</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">AND</span> RA.weekend_date = @SaturdayDate</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">WHERE</span> RA.family_id <span style="color: #0000ff">IS</span> <span style="color: #0000ff">NULL</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #008000">-- Calculate Attendance</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">UPDATE</span> CW</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">SET</span> </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        CW.first_attended = dbo.cust_ccv_funct_family_first_attended (CW.family_id),</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        CW.last_attended = dbo.cust_ccv_funct_family_last_attended (CW.family_id, CW.weekend_date),</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        CW.regular_attendee = </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">CASE</span> <span style="color: #0000ff">WHEN</span> LW.regular_attendee <span style="color: #0000ff">IS</span> <span style="color: #0000ff">NULL</span> <span style="color: #0000ff">OR</span> LW.regular_attendee = 0</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">THEN</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #008000">-- In ?</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">CASE</span> <span style="color: #0000ff">WHEN</span> (CW.times_gave_total &gt;= 3 <span style="color: #0000ff">AND</span> CW.times_gave_last_6_weeks &gt;= 1)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">OR</span> CW.times_attended_last_16_weeks &gt;= 8 </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">THEN</span> 1 <span style="color: #0000ff">ELSE</span> 0 <span style="color: #0000ff">END</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">ELSE</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #008000">-- Out ?</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">CASE</span> <span style="color: #0000ff">WHEN</span> DATEADD(week, 8, CW.last_gave) &lt; CW.weekend_date</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">AND</span> DATEADD(week, 4, CW.last_attended) &lt; CW.weekend_date</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">AND</span> CW.times_attended_last_16_weeks &lt; 8</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">THEN</span> 0 <span style="color: #0000ff">ELSE</span> 1 <span style="color: #0000ff">END</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">END</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">FROM</span> dtmt_estimated_regular_attendees CW</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">LEFT</span> <span style="color: #0000ff">OUTER</span> <span style="color: #0000ff">JOIN</span> dtmt_estimated_regular_attendees LW</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">ON</span> CW.family_id = LW.family_id</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">AND</span> CW.weekend_date = DATEADD(week, 1, LW.weekend_date)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">where</span> CW.weekend_date = @SaturdayDate</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #008000">-- Calculate Giving/Checking component of regular attendees</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">UPDATE</span> dtmt_estimated_regular_attendees</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">SET</span> </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        regular_attendee_g = </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">CASE</span> <span style="color: #0000ff">WHEN</span> DATEADD(week, 8, last_gave) &gt;= weekend_date</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">THEN</span> 1 <span style="color: #0000ff">ELSE</span> 0 <span style="color: #0000ff">END</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        regular_attendee_c = </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">CASE</span> <span style="color: #0000ff">WHEN</span> DATEADD(week, 4, last_attended) &gt;= weekend_date </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">OR</span> times_attended_last_16_weeks &gt;= 8</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">THEN</span> 1 <span style="color: #0000ff">ELSE</span> 0 <span style="color: #0000ff">END</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">WHERE</span> weekend_date = @SaturdayDate</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">AND</span> regular_attendee = 1</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">END</pre>
<p><!--CRLF--></div>
</div>
<p>&#160;</p>
<h3>Initial Load</h3>
<p>To initially load this table with past data we ran this script (and let it run for a while).</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">DECLARE</span> @WeekendDate datetime</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">SET</span> @WeekendDate = dbo.util_funct_saturday(<span style="color: #006080">'01/01/2006'</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">WHILE</span> @WeekendDate &lt; GETDATE()</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">BEGIN</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">EXEC</span> [cust_ccv_sp_dtmt_loadEstimatedRegularAttendees] @WeekendDate</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">SET</span> @WeekendDate = DATEADD(week, 1, @WeekendDate)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">END</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></div>
</div>
<h3>&#160;</h3>
<h3>Loss Report</h3>
<p>Jon mentioned the report that shows us each week who the eRA losses were.&#160; This proc will list families that became an eRA loss during any two dates.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">PROC</span> [dbo].[cust_ccv_sp_dtmt_loss_report]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">@FromDate datetime,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">@ToDate datetime</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">AS</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">SET</span> @FromDate = dbo.util_funct_saturday(@FromDate)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">SET</span> @ToDate = dbo.util_funct_saturday(@ToDate)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">select</span> p.*,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    tw.last_attended <span style="color: #0000ff">as</span> [<span style="color: #0000ff">Last</span> Attended],</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    tw.last_gave <span style="color: #0000ff">as</span> [<span style="color: #0000ff">Last</span> Gave]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">from</span> dtmt_estimated_regular_attendees tw</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">inner</span> <span style="color: #0000ff">join</span> core_v_merge_fields p <span style="color: #0000ff">on</span> p.person_id = dbo.core_funct_familyHead2(tw.family_id)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">left</span> <span style="color: #0000ff">outer</span> <span style="color: #0000ff">join</span> dtmt_estimated_regular_attendees lw </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">on</span> tw.family_id = lw.family_id</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">and</span> lw.weekend_date = @FromDate</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">where</span> tw.weekend_date = @ToDate</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">and</span> lw.regular_attendee = 1</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">and</span> tw.regular_attendee = 0</pre>
<p><!--CRLF--></div>
</div>
<h3>&#160;</h3>
<h3>Trending View</h3>
<p>This is a view that feeds some of our charts.&#160; It groups totals by weekend and shows the difference between the current weekend and the weekend 4 weeks prior.&#160; (four week rolling average).</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">VIEW</span> [dbo].[cust_ccv_v_dtmt_era_trend]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">AS</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">with</span> cte</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">as</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">(</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">select</span> </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        tw.weekend_date,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        tw.family_id,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> lw.regular_attendee = 1 <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> eRA_1,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> tw.regular_attendee = 1 <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> eRA_2,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> tw.regular_attendee = 1 <span style="color: #0000ff">and</span> (lw.regular_attendee <span style="color: #0000ff">is</span> <span style="color: #0000ff">null</span> <span style="color: #0000ff">or</span> lw.regular_attendee = 0)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> eRA_add,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> lw.regular_attendee = 1 <span style="color: #0000ff">and</span> (tw.regular_attendee <span style="color: #0000ff">is</span> <span style="color: #0000ff">null</span> <span style="color: #0000ff">or</span> tw.regular_attendee = 0)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> eRA_loss,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> lw.regular_attendee_g = 1 <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> eRAg_1,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> tw.regular_attendee_g = 1 <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> eRAg_2,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> tw.regular_attendee_g = 1 <span style="color: #0000ff">and</span> (lw.regular_attendee_g <span style="color: #0000ff">is</span> <span style="color: #0000ff">null</span> <span style="color: #0000ff">or</span> lw.regular_attendee_g = 0)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> eRAg_add,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> lw.regular_attendee_g = 1 <span style="color: #0000ff">and</span> (tw.regular_attendee_g <span style="color: #0000ff">is</span> <span style="color: #0000ff">null</span> <span style="color: #0000ff">or</span> tw.regular_attendee_g = 0)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> eRAg_loss,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> lw.regular_attendee_c = 1 <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> eRAc_1,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> tw.regular_attendee_c = 1 <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> eRAc_2,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> tw.regular_attendee_c = 1 <span style="color: #0000ff">and</span> (lw.regular_attendee_c <span style="color: #0000ff">is</span> <span style="color: #0000ff">null</span> <span style="color: #0000ff">or</span> lw.regular_attendee_c = 0)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> eRAc_add,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> lw.regular_attendee_c = 1 <span style="color: #0000ff">and</span> (tw.regular_attendee_c <span style="color: #0000ff">is</span> <span style="color: #0000ff">null</span> <span style="color: #0000ff">or</span> tw.regular_attendee_c = 0)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> eRAc_loss,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> tw.times_attended_last_16_weeks <span style="color: #0000ff">is</span> <span style="color: #0000ff">not</span> <span style="color: #0000ff">null</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> attended,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> tw.times_attended_last_16_weeks &gt;= 13 <span style="color: #0000ff">and</span> tw.times_attended_last_16_weeks &lt;= 16 </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> attendance_grade_a,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> tw.times_attended_last_16_weeks &gt;= 9 <span style="color: #0000ff">and</span> tw.times_attended_last_16_weeks &lt;= 12</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> attendance_grade_b,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> tw.times_attended_last_16_weeks &gt;= 5 <span style="color: #0000ff">and</span> tw.times_attended_last_16_weeks &lt;= 8</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> attendance_grade_c,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">case</span> <span style="color: #0000ff">when</span> tw.times_attended_last_16_weeks &gt;= 1 <span style="color: #0000ff">and</span> tw.times_attended_last_16_weeks &lt;= 4 </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">then</span> 1 <span style="color: #0000ff">else</span> 0 <span style="color: #0000ff">end</span> <span style="color: #0000ff">as</span> attendance_grade_d</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">from</span> dtmt_estimated_regular_attendees tw</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">left</span> <span style="color: #0000ff">outer</span> <span style="color: #0000ff">join</span> dtmt_estimated_regular_attendees lw </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">on</span> tw.family_id = lw.family_id</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">and</span> tw.weekend_date = DATEADD(week, 4, lw.weekend_date)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">WHERE</span> DATEADD(week, -4, tw.weekend_date) <span style="color: #0000ff">IN</span> (</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">SELECT</span> <span style="color: #0000ff">DISTINCT</span> weekend_date </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">FROM</span> dtmt_estimated_regular_attendees</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">WHERE</span> regular_attendee = 1 )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">select</span> </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    weekend_date,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRA_1) <span style="color: #0000ff">as</span> eRA_1,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRA_2) <span style="color: #0000ff">as</span> eRA_2,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRA_2) - <span style="color: #0000ff">sum</span>(eRA_1) <span style="color: #0000ff">as</span> eRA_gain,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">cast</span>((<span style="color: #0000ff">sum</span>(eRA_2) - <span style="color: #0000ff">sum</span>(eRA_1)) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2))/<span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRA_1) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2)) <span style="color: #0000ff">as</span> eRA_gain_percent,    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRA_add) <span style="color: #0000ff">as</span> eRA_add,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRA_add) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2))/<span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRA_1) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2)) <span style="color: #0000ff">as</span> eRA_add_percent,    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRA_loss) <span style="color: #0000ff">as</span> eRA_loss,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRA_loss) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2))/<span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRA_1) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2)) <span style="color: #0000ff">as</span> eRA_loss_percent,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRAg_1) <span style="color: #0000ff">as</span> eRAg_1,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRAg_2) <span style="color: #0000ff">as</span> eRAg_2,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRAg_2) - <span style="color: #0000ff">sum</span>(eRAg_1) <span style="color: #0000ff">as</span> eRAg_gain,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">cast</span>((<span style="color: #0000ff">sum</span>(eRAg_2) - <span style="color: #0000ff">sum</span>(eRAg_1)) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2))/<span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRA_1) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2)) <span style="color: #0000ff">as</span> eRAg_gain_percent,    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRAg_add) <span style="color: #0000ff">as</span> eRAg_add,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRAg_add) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2))/<span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRA_1) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2)) <span style="color: #0000ff">as</span> eRAg_add_percent,    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRAg_loss) <span style="color: #0000ff">as</span> eRAg_loss,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRAg_loss) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2))/<span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRA_1) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2)) <span style="color: #0000ff">as</span> eRAg_loss_percent,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRAc_1) <span style="color: #0000ff">as</span> eRAc_1,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRAc_2) <span style="color: #0000ff">as</span> eRAc_2,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRAc_2) - <span style="color: #0000ff">sum</span>(eRAc_1) <span style="color: #0000ff">as</span> eRAc_gain,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">cast</span>((<span style="color: #0000ff">sum</span>(eRAc_2) - <span style="color: #0000ff">sum</span>(eRAc_1)) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2))/<span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRA_1) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2)) <span style="color: #0000ff">as</span> eRAc_gain_percent,    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRAc_add) <span style="color: #0000ff">as</span> eRAc_add,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRAc_add) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2))/<span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRA_1) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2)) <span style="color: #0000ff">as</span> eRAc_add_percent,    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(eRAc_loss) <span style="color: #0000ff">as</span> eRAc_loss,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRAc_loss) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2))/<span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(eRA_1) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2)) <span style="color: #0000ff">as</span> eRAc_loss_percent,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(attended) <span style="color: #0000ff">as</span> attended,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(attendance_grade_a) <span style="color: #0000ff">as</span> attendance_grade_a,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(attendance_grade_a) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2))/<span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(attended) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2)) <span style="color: #0000ff">as</span> attendance_grade_a_percent,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(attendance_grade_b) <span style="color: #0000ff">as</span> attendance_grade_b,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(attendance_grade_b) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2))/<span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(attended) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2)) <span style="color: #0000ff">as</span> attendance_grade_b_percent,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(attendance_grade_c) <span style="color: #0000ff">as</span> attendance_grade_c,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(attendance_grade_c) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2))/<span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(attended) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2)) <span style="color: #0000ff">as</span> attendance_grade_c_percent,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">sum</span>(attendance_grade_d) <span style="color: #0000ff">as</span> attendance_grade_d,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(attendance_grade_d) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2))/<span style="color: #0000ff">cast</span>(<span style="color: #0000ff">sum</span>(attended) <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(9,2)) <span style="color: #0000ff">as</span> attendance_grade_d_percent</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">from</span> cte</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">group</span> <span style="color: #0000ff">by</span> weekend_date</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">--<span style="color: #0000ff">order</span> <span style="color: #0000ff">by</span> weekend_date <span style="color: #0000ff">desc</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">GO</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></div>
</div>
<h3>&#160;</h3>
<h3>First/Last Attended</h3>
<p>These functions for determining when a family first and last attended are used by the proc above.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">function</span> [dbo].[cust_ccv_funct_family_first_attended] (@FamilyID <span style="color: #0000ff">int</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">returns</span> datetime</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">as</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">begin</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">DECLARE</span> @FirstAttended datetime </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">SET</span> @FirstAttended = (</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">SELECT</span> <span style="color: #0000ff">MIN</span>(O.occurrence_start_time) <span style="color: #0000ff">AS</span> first_attended</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">FROM</span> core_family_member FM</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_occurrence_attendance OA  <span style="color: #0000ff">ON</span> OA.person_id = FM.person_id</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_occurrence O <span style="color: #0000ff">ON</span> O.occurrence_id = OA.occurrence_id</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_occurrence_type OT <span style="color: #0000ff">ON</span> OT.occurrence_type_id = O.occurrence_type</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">WHERE</span> FM.family_id = @FamilyID</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">AND</span> OA.attended = 1</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">AND</span> OT.is_service = 1</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">AND</span> OT.occurrence_type_id &lt;&gt; 6 ) <span style="color: #008000">-- High School</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">IF</span> @FirstAttended <span style="color: #0000ff">IS</span> <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">SET</span> @FirstAttended = dbo.util_funct_saturday(@FirstAttended)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">RETURN</span> @FirstAttended</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">end</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">function</span> [dbo].[cust_ccv_funct_family_last_attended] (@FamilyID <span style="color: #0000ff">int</span>, @WeekendDate datetime)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">returns</span> datetime</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">as</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">begin</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">DECLARE</span> @LastAttended datetime </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">SET</span> @LastAttended = (</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">SELECT</span> <span style="color: #0000ff">MAX</span>(O.occurrence_start_time) <span style="color: #0000ff">AS</span> last_attended</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">FROM</span> core_family_member FM</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_occurrence_attendance OA  <span style="color: #0000ff">ON</span> OA.person_id = FM.person_id</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_occurrence O <span style="color: #0000ff">ON</span> O.occurrence_id = OA.occurrence_id</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_occurrence_type OT <span style="color: #0000ff">ON</span> OT.occurrence_type_id = O.occurrence_type</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">WHERE</span> FM.family_id = @FamilyID</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">AND</span> dbo.util_funct_mergedDate(O.occurrence_start_time,6) &lt;= @WeekendDate</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">AND</span> OA.attended = 1</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">AND</span> OT.is_service = 1</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">AND</span> OT.occurrence_type_id &lt;&gt; 6 ) <span style="color: #008000">-- High School</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">RETURN</span> @LastAttended</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">end</span></pre>
<p><!--CRLF--></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2009/10/era/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Aggregate Type</title>
		<link>http://www.david-turner.net/2009/09/aggregate-type/</link>
		<comments>http://www.david-turner.net/2009/09/aggregate-type/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 20:14:44 +0000</pubDate>
		<dc:creator>David Turner</dc:creator>
				<category><![CDATA[Arena]]></category>

		<guid isPermaLink="false">http://www.david-turner.net/2009/09/aggregate-type/</guid>
		<description><![CDATA[As you begin to use metrics more, you may come across the need to summarize some of the data that gets collected in metrics.&#160; Fortunately, there is a little hidden attribute on each metric called Aggregate Type.&#160; While aggregate type isn’t really used by the Arena UI, it can be useful in various reporting scenarios.
Say [...]]]></description>
			<content:encoded><![CDATA[<p>As you begin to use metrics more, you may come across the need to summarize some of the data that gets collected in metrics.&#160; Fortunately, there is a little hidden attribute on each metric called Aggregate Type.&#160; While aggregate type isn’t really used by the Arena UI, it can be useful in various reporting scenarios.</p>
<p>Say you want to create a monthly summary report that displays metric data summarized for the last 12 months.&#160; If you have a metric for weekend attendance, and another metric for baptisms, you’d probably want to summarize those numbers differently when reporting monthly numbers.&#160; For example, for attendance, you’d want to report the maximum number (weekend with the greatest attendance), but for baptisms, you’d probably want the total number (sum) during the month.&#160; That’s where aggregate type comes in.</p>
<p>By default, you will not see an Aggregate field when editing metrics.&#160; You’ll need to turn on the “Show Aggregate Field” module setting on the Metric Chart module.&#160; Once you’ve turned this setting on, you’ll be able to set aggregate types for each metric.&#160; Possible values are Average, Total, Maximum, and Minimum.</p>
<p>Once you’re using aggregate types, you can then take advantage of a couple SQL functions when writing custom reports…</p>
<p><b>mtrc_get_aggregate_value      <br /></b>When you pass this function a metric id and start and end date, it will return a value for that metric based on the aggregate type.&#160; For example, if the aggregate type is Maximum, then the largest metric value between the start and end dates is returned.&#160; If the aggregate type is Average, then the average of all metric values between the dates is returned. etc. etc.</p>
<p><b>mtrc_get_monthly_values      <br /></b>When you pass this function a parent metric id and a start year, and month, it will return a table of all the child metrics and their respective aggregate values for the following 12 months.&#160; This function uses the previous function to determine the aggregate values for each metric and month.</p>
<p>We use both of these functions to generate the type of report that <a href="http://www.jonedmiston.com/?p=178" target="_blank">Jon blogged about here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2009/09/aggregate-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>“Regular” Attendees</title>
		<link>http://www.david-turner.net/2009/08/regular-attendees/</link>
		<comments>http://www.david-turner.net/2009/08/regular-attendees/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 17:58:30 +0000</pubDate>
		<dc:creator>David Turner</dc:creator>
				<category><![CDATA[Arena]]></category>

		<guid isPermaLink="false">http://www.david-turner.net/2009/08/regular-attendees/</guid>
		<description><![CDATA[I often get requests from fellow staff members asking for a report about their “Regular” attendees.&#160; After I explain to them that SQL doesn’t have a “Regular” key word, and that I need to know exactly what they mean by “regular” they usually&#160; go away to think about it and never end up coming back [...]]]></description>
			<content:encoded><![CDATA[<p>I often get requests from fellow staff members asking for a report about their “Regular” attendees.&#160; After I explain to them that SQL doesn’t have a “Regular” key word, and that I need to know exactly what they mean by “regular” they usually&#160; go away to think about it and never end up coming back <img src='http://www.david-turner.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Unfortunately they’ve begun to figure this out.&#160; My latest report request was for a list of the parents of all 2nd –6th graders who have attended services at least twice a month for the previous 6 months, and if and where the parent might be serving.&#160; Ok, that’s specific. Now how do I get the list?</p>
<p>Writing the SQL proved to be more challenging than I expected.&#160; After a couple iterations, I finally just created a “utility” stored procedure that would accept a list of attendance types, a minimum monthly attendance rate, and the number of months to check the attendance.&#160; It then returns a list of people who met that criteria.</p>
<p>Since it might come in handy for others, I share it here…</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">PROC</span> [dbo].[cust_ccv_regular_attenders]
@OccurrenceTypeIDs <span style="color: #0000ff">varchar</span>(200),
@MonthsBack <span style="color: #0000ff">int</span>,
@MinMonthlyAttendance <span style="color: #0000ff">int</span>

<span style="color: #0000ff">AS</span>

/********************************************************************
*    cust_ccv_regular_attenders
*
*    <span style="color: #0000ff">Procedure</span> <span style="color: #0000ff">to</span> <span style="color: #0000ff">return</span> list <span style="color: #0000ff">of</span> people who have attended <span style="color: #0000ff">specific</span>
*   occurrence type(s) a <span style="color: #0000ff">specific</span> number <span style="color: #0000ff">of</span> times <span style="color: #0000ff">each</span> <span style="color: #0000ff">month</span> <span style="color: #0000ff">for</span> a
*    <span style="color: #0000ff">specific</span> number <span style="color: #0000ff">of</span> months back.
*
*    <span style="color: #0000ff">Parameters</span>:
*        @OccurrenceTypeIDs - Comma delimeted list <span style="color: #0000ff">of</span> occurrence type
*            ID<span style="color: #006080">'s to check
*        @MonthsBack  - Number of months back that minimum attendance
*            has to have occurred
*        @MinMonthlyAttendance - The number of times each month that
*            person needs to have attended
*
*********************************************************************/

BEGIN

    DECLARE @Dates varchar(max)
    SET @Dates = '</span><span style="color: #006080">'
    DECLARE @Where varchar(max)
    SET @Where = '</span><span style="color: #006080">'

    DECLARE @Date datetime
    SET @Date = CAST(MONTH(GETDATE()) AS varchar) + '</span>/1/<span style="color: #006080">' + CAST(YEAR(GETDATE()) AS varchar)
    SET @Date = DATEADD(month, -1, @Date)

    DECLARE @Month int
    SET @Month = -1

    WHILE @Date &gt; DATEADD(month, (0 - (@MonthsBack + 1)), GETDATE())
    BEGIN

        IF @Dates &lt;&gt; '</span><span style="color: #006080">'
            SET @Dates = @Dates + '</span>,<span style="color: #006080">'
        SET @Dates = @Dates + '</span>[<span style="color: #006080">' + CAST(MONTH(@Date) AS varchar) + '</span>/1/<span style="color: #006080">' + CAST(YEAR(@Date) AS varchar) + '</span>]<span style="color: #006080">'

        IF @Where = '</span><span style="color: #006080">'
            SET @Where = '</span> <span style="color: #0000ff">WHERE</span> <span style="color: #006080">'
        ELSE
            SET @Where = @Where + '</span> <span style="color: #0000ff">AND</span> <span style="color: #006080">'
        SET @Where = @Where + '</span>[<span style="color: #006080">' + CAST(MONTH(@Date) AS varchar) + '</span>/1/<span style="color: #006080">' + CAST(YEAR(@Date) AS varchar) + '</span>] &gt;= <span style="color: #006080">' + CAST(@MinMonthlyAttendance AS varchar)

        SET @Date = DATEADD(month, -1, @Date)
    END

    DECLARE @Sql nvarchar(max)
    SET @Sql =
    '</span><span style="color: #0000ff">WITH</span> CTE
    <span style="color: #0000ff">AS</span>
    (
        <span style="color: #0000ff">SELECT</span> *
        <span style="color: #0000ff">FROM</span> (
            <span style="color: #0000ff">SELECT</span>
                OA.person_id,
                <span style="color: #0000ff">CAST</span>(<span style="color: #0000ff">MONTH</span>(service_time) <span style="color: #0000ff">AS</span> <span style="color: #0000ff">varchar</span>) + <span style="color: #006080">''</span>/1/<span style="color: #006080">''</span> + <span style="color: #0000ff">CAST</span>(<span style="color: #0000ff">YEAR</span>(service_time) <span style="color: #0000ff">AS</span> <span style="color: #0000ff">varchar</span>) <span style="color: #0000ff">as</span> service_month
            <span style="color: #0000ff">FROM</span> core_occurrence_attendance OA
            <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_v_occurrence_service O <span style="color: #0000ff">ON</span> O.occurrence_id = OA.occurrence_id
            <span style="color: #0000ff">WHERE</span> O.occurrence_type_id <span style="color: #0000ff">in</span> (<span style="color: #006080">' + @OccurrenceTypeIDs + '</span>)
            <span style="color: #0000ff">AND</span> OA.attended = 1
            <span style="color: #0000ff">AND</span> OA.person_id <span style="color: #0000ff">IS</span> <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>
        )
        MS
        PIVOT (
            <span style="color: #0000ff">COUNT</span>(service_month)
            <span style="color: #0000ff">FOR</span> service_month
            <span style="color: #0000ff">IN</span> (<span style="color: #006080">' + @Dates + '</span>)
        ) <span style="color: #0000ff">AS</span> pvt
    )
    <span style="color: #0000ff">SELECT</span> person_id
    <span style="color: #0000ff">FROM</span> CTE ' + @<span style="color: #0000ff">Where</span>

    --<span style="color: #0000ff">SELECT</span> @<span style="color: #0000ff">Sql</span>
    <span style="color: #0000ff">EXEC</span> sp_executesql @<span style="color: #0000ff">Sql</span>;

END</pre>
</div>
<p>Since that is now just a utility procedure, I needed another procedure to specify the elementary age occurrence types, join to the parents and find their serving areas…</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">PROC</span> cust_ccv_sp_elementary_reg_attender_parents

<span style="color: #0000ff">AS</span>

<span style="color: #0000ff">DECLARE</span> @RegularAttenders <span style="color: #0000ff">table</span>
(
    person_id <span style="color: #0000ff">int</span> <span style="color: #0000ff">primary</span> <span style="color: #0000ff">key</span> <span style="color: #0000ff">not</span> <span style="color: #0000ff">null</span>
)

INSERT <span style="color: #0000ff">INTO</span> @RegularAttenders
<span style="color: #0000ff">EXEC</span> [cust_ccv_regular_attenders] <span style="color: #006080">'40,41,43,68,69'</span>, 6, 2

<span style="color: #0000ff">SELECT</span> <span style="color: #0000ff">DISTINCT</span>
    P.*,
    dbo.core_funct_profile_name_list(P.person_id, 2) <span style="color: #0000ff">AS</span> Serving
<span style="color: #0000ff">FROM</span> @RegularAttenders RA
<span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_family_member C
    <span style="color: #0000ff">ON</span> C.person_id = RA.person_id
    <span style="color: #0000ff">AND</span> C.role_luid = 31
<span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_family_member A
    <span style="color: #0000ff">ON</span> A.family_id = C.family_id
    <span style="color: #0000ff">AND</span> A.role_luid = 29
<span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_v_merge_fields P
    <span style="color: #0000ff">ON</span> P.person_id = A.person_id
<span style="color: #0000ff">ORDER</span> <span style="color: #0000ff">BY</span> P.last_name, P.nick_name</pre>
</div>
<p>I created a new page in <a href="http://www.arenachms.com" target="_blank">Arena</a> that used the ReportGridFromQuery module, pointed it to this procedure, and now the elementary kids staff member can track down all the parents of their “regular” attendees who are not already serving and hit them up to serve in their area.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2009/08/regular-attendees/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arena as a CMS</title>
		<link>http://www.david-turner.net/2009/06/arena-as-a-cms/</link>
		<comments>http://www.david-turner.net/2009/06/arena-as-a-cms/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 23:34:14 +0000</pubDate>
		<dc:creator>David Turner</dc:creator>
				<category><![CDATA[Arena]]></category>
		<category><![CDATA[CCV]]></category>

		<guid isPermaLink="false">http://www.david-turner.net/2009/06/arena-as-a-cms/</guid>
		<description><![CDATA[Earlier today, I received an email asking what functionality Arena provides when used to drive a church’s public website.&#160; I thought I’d share my response…
Content Management System (CMS)
Arena is a CMS.&#160; It may not be the fanciest and easiest to use CMS out there, but it provides all the functionality for configuring portals, templates, pages, [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier today, I received an email asking what functionality <a href="http://www.arenachms.com" target="_blank">Arena</a> provides when used to drive a church’s public website.&#160; I thought I’d share my response…</p>
<h3>Content Management System (CMS)</h3>
<p>Arena is a CMS.&#160; It may not be the fanciest and easiest to use CMS out there, but it provides all the functionality for configuring portals, templates, pages, modules, security, content, etc.&#160; And by using templates, you can create an Arena driven site to look anyway you’d like.&#160; The look and functionality of your site is only limited by the creativity of your designer.&#160; You can be as “Web 2.0” and as you’d like using Arena templates.</p>
<p>The biggest advantage of using Arena as your CMS, however, is it’s integration with all the information you already have in the Arena membership system and the modules that have been created to take advantage of that information.</p>
<h3>Promotions</h3>
<p>The most powerful area of integration with Arena is promotions. Church staff can add promotions in Arena that are categorized, prioritized and approved and will then automatically be displayed on your public website.&#160; </p>
<p>For example <a href="http://www.canyonridge.org/" target="_blank">Canyon Ridge</a> has configured a promotion display module to display the top three “All Church” promotions at the bottom of their home page…</p>
<p><a href="http://www.david-turner.net/wp-content/uploads/2009/06/clip-image002.jpg"><img title="clip_image002" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="385" alt="clip_image002" src="http://www.david-turner.net/wp-content/uploads/2009/06/clip-image002-thumb.jpg" width="431" border="0" /></a></p>
<p>There are several types of promotion display modules, each of which display your promotions in different ways.&#160; A Flash module is even provided for animating Arena promotions.&#160; An example of the Flash module can be seen on <a href="http://www.ccvstars.com/arena/default.aspx?page=2386" target="_blank">this CCV Stars page</a>. </p>
<p>With promotions, the “web guy” doesn’t have to worry about adding or removing content when appropriate. As soon as a promotion’s date has passed, it is automatically removed from the site. Promotions can also be configured for different ministry areas (Men’s, Women’s Singles, etc.) and the website would show just promotions specific to those areas on their respective web pages.</p>
<h3>But There’s More…</h3>
<p>In addition to promotions, Arena can also drive the following functionality on your public site:</p>
<ul>
<li>Small Group Leader Toolbox (lay leaders can manage groups)</li>
<li><a href="http://www.ccvonline.com/Arena/default.aspx?page=12837">Group Finder</a> (several options including geographically based, affinity based, etc.)</li>
<li><a href="http://www.ccvonline.com/Arena/default.aspx?page=12529">Online Giving</a></li>
<li><a href="http://www.ccvonline.com/Arena/default.aspx?page=12248">Event Calendar</a></li>
<li><a href="http://www.ccvonline.com/Arena/default.aspx?page=12743&amp;event=14760">Event Registration</a></li>
<li><a href="http://www.ccvonline.com/Arena/default.aspx?page=12445">Prayer Requests</a></li>
<li><a href="http://www.ccvonline.com/Arena/default.aspx?page=12658">Personalized Subscriptions to promotions</a> (through RSS or Email) </li>
<li>Online Folder/File browser for securing and sharing digital content</li>
<li><a href="http://www.ccvonline.com/Arena/default.aspx?Page=12250">Podcasting</a>/Blogging</li>
<li><a href="http://www.ccvonline.com/Arena/default.aspx?page=12204">Classifieds</a> (One of the most visited areas of CCV’s site)</li>
<li>ECards</li>
<li><a href="http://www.ccvonline.com/Arena/default.aspx?page=12216">Newsletters</a></li>
<li><a href="http://www.ccvgarage.com/Arena/Default.aspx?page=472">Polls</a></li>
<li><a href="http://www.ccvonline.com/Arena/default.aspx?page=12813">Serving Opportunities</a></li>
<li><a href="http://www.ccvstars.com/Arena/default.aspx?page=2523&amp;team=7300">Sports Team information</a> (Team info, standings, etc)</li>
<li><a href="http://www.ccvonline.com/Arena/default.aspx?page=12615&amp;category=8bae6fb6-cb8e-4e8b-a5fb-bb26192472d1">Photo Albums</a></li>
<li><a href="http://www.ccvonline.com/Arena/default.aspx?page=12194">Staff Pages</a></li>
<li><a href="http://www.ccvonline.com/Arena/default.aspx?page=12604">Employment Opportunities</a></li>
</ul>
<p>&#160;</p>
<p>So, if you’re using Arena as your ChMS and not as your CMS, your going to miss out on a lot of built-in integration.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2009/06/arena-as-a-cms/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Staff Anniversaries</title>
		<link>http://www.david-turner.net/2009/05/staff-anniversaries/</link>
		<comments>http://www.david-turner.net/2009/05/staff-anniversaries/#comments</comments>
		<pubDate>Thu, 28 May 2009 11:40:18 +0000</pubDate>
		<dc:creator>David Turner</dc:creator>
				<category><![CDATA[Arena]]></category>

		<guid isPermaLink="false">http://www.david-turner.net/2009/05/staff-anniversaries/</guid>
		<description><![CDATA[For a long time, we’ve been putting our staff anniversaries on our Arena home page each month…
 
I’m ashamed to say that until now, our department admin has been doing this manually each month.&#160; I also noticed that she recently started changing the highlighting each day to indicate which anniversaries in the month had already [...]]]></description>
			<content:encoded><![CDATA[<p>For a long time, we’ve been putting our staff anniversaries on our <a href="http://www.arenachms.com" target="_blank">Arena</a> home page each month…</p>
<p><a href="http://www.david-turner.net/wp-content/uploads/2009/05/image.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="196" alt="image" src="http://www.david-turner.net/wp-content/uploads/2009/05/image-thumb.png" width="499" border="0" /></a> </p>
<p>I’m ashamed to say that until now, our department admin has been doing this manually each month.&#160; I also noticed that she recently started changing the highlighting each day to indicate which anniversaries in the month had already passed.&#160; Obviously a lot of manual work for what can easily be automated.</p>
<p>Since we’re tracking all this information in Arena, this was a perfect scenario for the <em>HTML from Stored Procedure</em> module.</p>
<p>&#160;</p>
<p>First a stored procedure is needed to generate the HTML…</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">PROC</span> [dbo].[cust_ccv_sp_staff_anniversaries]
@HireDateAttrID <span style="color: #0000ff">int</span>,
@PositionAttrID <span style="color: #0000ff">int</span>
<span style="color: #0000ff">AS</span>

<span style="color: #0000ff">DECLARE</span> @MonthName <span style="color: #0000ff">varchar</span>(12)
<span style="color: #0000ff">DECLARE</span> @HtmlMsgPtr <span style="color: #0000ff">binary</span>(16)
<span style="color: #0000ff">DECLARE</span> @TempMessage <span style="color: #0000ff">varchar</span>(8000)

<span style="color: #0000ff">DECLARE</span> @Today datetime
<span style="color: #0000ff">SET</span> @Today = GETDATE()

<span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">TABLE</span> ##StaffHtmlTable ([html] text)

INSERT <span style="color: #0000ff">INTO</span> ##StaffHtmlTable <span style="color: #0000ff">VALUES</span> (<span style="color: #006080">'&lt;hr/&gt;'</span>)
<span style="color: #0000ff">SELECT</span> @HtmlMsgPtr = TEXTPTR([html])
<span style="color: #0000ff">FROM</span> ##StaffHtmlTable

<span style="color: #0000ff">SET</span> @TempMessage = <span style="color: #006080">'&lt;table style=&quot;width: 570px; height: 201px; &quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;'</span> +
    <span style="color: #006080">'&lt;td class=&quot;highlightText&quot; valign=&quot;top&quot; align=&quot;left&quot;&gt;'</span> +
    <span style="color: #006080">'&lt;img src=&quot;/Arena/Content/HtmlImages/Public/Images/General/icon_birthday.gif&quot; /&gt;'</span> +
    <span style="color: #006080">'&lt;strong&gt;&lt;font color=&quot;#808080&quot; size=&quot;3&quot;&gt;'</span> + DATENAME(<span style="color: #0000ff">month</span>, @Today) + <span style="color: #006080">' Birthdays&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;'</span> +
    <span style="color: #006080">'&lt;td class=&quot;highlightText&quot; valign=&quot;top&quot; align=&quot;left&quot;&gt;'</span> +
    <span style="color: #006080">'&lt;img src=&quot;/Arena/Content/HtmlImages/Public/Images/General/award.jpg&quot; /&gt;'</span> +
    <span style="color: #006080">'&lt;strong&gt;&lt;font color=&quot;#808080&quot; size=&quot;3&quot;&gt;'</span> + DATENAME(<span style="color: #0000ff">month</span>, @Today) +
    <span style="color: #006080">' Staff Years of Service&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;highlightText&quot; valign=&quot;top&quot;&gt;'</span>
<span style="color: #0000ff">UPDATETEXT</span> ##StaffHtmlTable.[html] @HtmlMsgPtr <span style="color: #0000ff">null</span> 0 @TempMessage

<span style="color: #0000ff">DECLARE</span> @StaffName <span style="color: #0000ff">varchar</span>(100)
<span style="color: #0000ff">DECLARE</span> @AnnivDate datetime
<span style="color: #0000ff">DECLARE</span> @<span style="color: #0000ff">Position</span> <span style="color: #0000ff">varchar</span>(250)

<span style="color: #0000ff">DECLARE</span> BirthDateCursor <span style="color: #0000ff">CURSOR</span> READ_ONLY <span style="color: #0000ff">FOR</span>
<span style="color: #0000ff">SELECT</span>
    nick_name + <span style="color: #006080">' '</span> + last_name,
    birth_date
<span style="color: #0000ff">FROM</span> core_person
<span style="color: #0000ff">WHERE</span> staff_member = 1
<span style="color: #0000ff">AND</span> birth_date &lt;&gt; <span style="color: #006080">'1/1/1900'</span>
<span style="color: #0000ff">AND</span> <span style="color: #0000ff">MONTH</span>(birth_date) = <span style="color: #0000ff">MONTH</span>(@Today)
<span style="color: #0000ff">ORDER</span> <span style="color: #0000ff">BY</span> <span style="color: #0000ff">DAY</span>(birth_Date), last_name, nick_name

<span style="color: #0000ff">OPEN</span> BirthDateCursor

<span style="color: #0000ff">FETCH</span> <span style="color: #0000ff">NEXT</span> <span style="color: #0000ff">FROM</span> BirthDateCursor
<span style="color: #0000ff">INTO</span>    @StaffName,
        @AnnivDate

<span style="color: #0000ff">WHILE</span> (@@FETCH_STATUS &lt;&gt; -1)
<span style="color: #0000ff">BEGIN</span>

    <span style="color: #0000ff">IF</span> (@@FETCH_STATUS = 0)
    <span style="color: #0000ff">BEGIN</span>

        <span style="color: #008000">-- Date</span>
        <span style="color: #0000ff">IF</span> <span style="color: #0000ff">DAY</span>(@AnnivDate) &lt; <span style="color: #0000ff">DAY</span>(@Today)
            <span style="color: #0000ff">SET</span> @TempMessage = <span style="color: #006080">'&lt;font color=&quot;#a9a9a9&quot;&gt;'</span>
        <span style="color: #0000ff">ELSE</span>
            <span style="color: #0000ff">SET</span> @TempMessage = <span style="color: #006080">'&lt;font color=&quot;#000000&quot;&gt;'</span>
        <span style="color: #0000ff">SET</span> @TempMessage = @TempMessage + <span style="color: #0000ff">CAST</span>(<span style="color: #0000ff">MONTH</span>(@AnnivDate) <span style="color: #0000ff">as</span> <span style="color: #0000ff">varchar</span>) + <span style="color: #006080">'/'</span> + <span style="color: #0000ff">CAST</span>(<span style="color: #0000ff">DAY</span>(@AnnivDate) <span style="color: #0000ff">as</span> <span style="color: #0000ff">varchar</span>)
        <span style="color: #0000ff">IF</span> <span style="color: #0000ff">DAY</span>(@AnnivDate) &lt; 10
            <span style="color: #0000ff">SET</span> @TempMessage = @TempMessage + <span style="color: #006080">'&amp;nbsp;&amp;nbsp;'</span>
        <span style="color: #0000ff">ELSE</span>
            <span style="color: #0000ff">SET</span> @TempMessage = @TempMessage + <span style="color: #006080">'&amp;nbsp;'</span>

        <span style="color: #0000ff">SET</span> @TempMessage = @TempMessage + <span style="color: #006080">'&lt;strong&gt;'</span> + @StaffName + <span style="color: #006080">'&lt;/strong&gt;&lt;/font&gt;&lt;br/&gt;'</span>
        <span style="color: #0000ff">UPDATETEXT</span> ##StaffHtmlTable.[html] @HtmlMsgPtr <span style="color: #0000ff">null</span> 0 @TempMessage

    <span style="color: #0000ff">END</span>

    <span style="color: #0000ff">FETCH</span> <span style="color: #0000ff">NEXT</span> <span style="color: #0000ff">FROM</span> BirthDateCursor
    <span style="color: #0000ff">INTO</span>    @StaffName,
            @AnnivDate

<span style="color: #0000ff">END</span>

<span style="color: #0000ff">CLOSE</span> BirthDateCursor
<span style="color: #0000ff">DEALLOCATE</span> BirthDateCursor

<span style="color: #0000ff">SET</span> @TempMessage = <span style="color: #006080">'&lt;/td&gt;&lt;td class=&quot;highlightText&quot; valign=&quot;top&quot;&gt;'</span>
<span style="color: #0000ff">UPDATETEXT</span> ##StaffHtmlTable.[html] @HtmlMsgPtr <span style="color: #0000ff">null</span> 0 @TempMessage

<span style="color: #0000ff">DECLARE</span> HireDateCursor <span style="color: #0000ff">CURSOR</span> READ_ONLY <span style="color: #0000ff">FOR</span>
<span style="color: #0000ff">SELECT</span>
    nick_name + <span style="color: #006080">' '</span> + last_name,
    HD.datetime_value,
    POS.varchar_value
<span style="color: #0000ff">FROM</span> core_person P
<span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_person_attribute HD
    <span style="color: #0000ff">ON</span> HD.person_id = P.person_id
    <span style="color: #0000ff">AND</span> HD.attribute_id = @HireDateAttrID
<span style="color: #0000ff">LEFT</span> <span style="color: #0000ff">OUTER</span> <span style="color: #0000ff">JOIN</span> core_person_attribute POS
    <span style="color: #0000ff">ON</span> POS.person_id = P.person_id
    <span style="color: #0000ff">AND</span> POS.attribute_id = @PositionAttrID
<span style="color: #0000ff">WHERE</span> P.staff_member = 1
<span style="color: #0000ff">AND</span> ISNULL(<span style="color: #0000ff">MONTH</span>(HD.datetime_value),0) = <span style="color: #0000ff">MONTH</span>(@Today)
<span style="color: #0000ff">AND</span> ISNULL(<span style="color: #0000ff">YEAR</span>(HD.datetime_value),0) &lt; <span style="color: #0000ff">YEAR</span>(@Today)
<span style="color: #0000ff">ORDER</span> <span style="color: #0000ff">BY</span> ISNULL(<span style="color: #0000ff">DAY</span>(HD.datetime_value),0), last_name, nick_name

<span style="color: #0000ff">OPEN</span> HireDateCursor

<span style="color: #0000ff">FETCH</span> <span style="color: #0000ff">NEXT</span> <span style="color: #0000ff">FROM</span> HireDateCursor
<span style="color: #0000ff">INTO</span>    @StaffName,
        @AnnivDate,
        @<span style="color: #0000ff">Position</span>

<span style="color: #0000ff">WHILE</span> (@@FETCH_STATUS &lt;&gt; -1)
<span style="color: #0000ff">BEGIN</span>

    <span style="color: #0000ff">IF</span> (@@FETCH_STATUS = 0)
    <span style="color: #0000ff">BEGIN</span>

        <span style="color: #0000ff">DECLARE</span> @Years <span style="color: #0000ff">int</span>
        <span style="color: #0000ff">SET</span> @Years = <span style="color: #0000ff">YEAR</span>(@Today) - <span style="color: #0000ff">YEAR</span>(@AnnivDate)

        <span style="color: #008000">-- Date</span>
        <span style="color: #0000ff">IF</span> <span style="color: #0000ff">DAY</span>(@AnnivDate) &lt; <span style="color: #0000ff">DAY</span>(@Today)
            <span style="color: #0000ff">SET</span> @TempMessage = <span style="color: #006080">'&lt;font color=&quot;#a9a9a9&quot;&gt;'</span>
        <span style="color: #0000ff">ELSE</span>
            <span style="color: #0000ff">SET</span> @TempMessage = <span style="color: #006080">'&lt;font color=&quot;#000000&quot;&gt;'</span>
        <span style="color: #0000ff">SET</span> @TempMessage = @TempMessage + <span style="color: #0000ff">CAST</span>(<span style="color: #0000ff">MONTH</span>(@AnnivDate) <span style="color: #0000ff">as</span> <span style="color: #0000ff">varchar</span>) + <span style="color: #006080">'/'</span> + <span style="color: #0000ff">CAST</span>(<span style="color: #0000ff">DAY</span>(@AnnivDate) <span style="color: #0000ff">as</span> <span style="color: #0000ff">varchar</span>)
        <span style="color: #0000ff">IF</span> <span style="color: #0000ff">DAY</span>(@AnnivDate) &lt; 10
            <span style="color: #0000ff">SET</span> @TempMessage = @TempMessage + <span style="color: #006080">'&amp;nbsp;&amp;nbsp;'</span>
        <span style="color: #0000ff">ELSE</span>
            <span style="color: #0000ff">SET</span> @TempMessage = @TempMessage + <span style="color: #006080">'&amp;nbsp;'</span>

        <span style="color: #0000ff">SET</span> @TempMessage = @TempMessage + <span style="color: #006080">'&lt;strong&gt;'</span> + @StaffName + <span style="color: #006080">'&lt;/strong&gt;, '</span> + @<span style="color: #0000ff">Position</span> + <span style="color: #006080">' - &lt;strong&gt;'</span> + <span style="color: #0000ff">CAST</span>(@Years <span style="color: #0000ff">as</span> <span style="color: #0000ff">varchar</span>)
        <span style="color: #0000ff">IF</span> @Years &gt; 1
        <span style="color: #0000ff">BEGIN</span>
            <span style="color: #0000ff">IF</span> @Years &gt;= 5
                <span style="color: #0000ff">SET</span> @TempMessage = @TempMessage + <span style="color: #006080">' Years!'</span>
            <span style="color: #0000ff">ELSE</span>
                <span style="color: #0000ff">SET</span> @TempMessage = @TempMessage + <span style="color: #006080">' Years'</span>
        <span style="color: #0000ff">END</span>
        <span style="color: #0000ff">ELSE</span>
            <span style="color: #0000ff">SET</span> @TempMessage = @TempMessage + <span style="color: #006080">' Year'</span>

        <span style="color: #0000ff">SET</span> @TempMessage = @TempMessage + <span style="color: #006080">'&lt;/strong&gt;&lt;/font&gt;&lt;br/&gt;'</span>
        <span style="color: #0000ff">UPDATETEXT</span> ##StaffHtmlTable.[html] @HtmlMsgPtr <span style="color: #0000ff">null</span> 0 @TempMessage

    <span style="color: #0000ff">END</span>

    <span style="color: #0000ff">FETCH</span> <span style="color: #0000ff">NEXT</span> <span style="color: #0000ff">FROM</span> HireDateCursor
    <span style="color: #0000ff">INTO</span>    @StaffName,
            @AnnivDate,
            @<span style="color: #0000ff">Position</span>

<span style="color: #0000ff">END</span>

<span style="color: #0000ff">CLOSE</span> HireDateCursor
<span style="color: #0000ff">DEALLOCATE</span> HireDateCursor

<span style="color: #0000ff">SET</span> @TempMessage = <span style="color: #006080">'&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;'</span>
<span style="color: #0000ff">UPDATETEXT</span> ##StaffHtmlTable.[html] @HtmlMsgPtr <span style="color: #0000ff">null</span> 0 @TempMessage

<span style="color: #0000ff">SELECT</span> [html] <span style="color: #0000ff">FROM</span> ##StaffHtmlTable

<span style="color: #0000ff">DROP</span> <span style="color: #0000ff">TABLE</span> ##StaffHtmlTable</pre>
</div>
<p>&#160;</p>
<p>This stored procedure expects a couple person attribute IDs for the Hire Date and Position…</p>
<p><a href="http://www.david-turner.net/wp-content/uploads/2009/05/image1.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="353" alt="image" src="http://www.david-turner.net/wp-content/uploads/2009/05/image-thumb1.png" width="519" border="0" /></a> </p>
<p>&#160;</p>
<p>And then a new <em>HTML From Stored Procedure</em> module is added to our Arena homepage. Notice the two person attribute ID values that are passed to the stored procedure in the Parameters setting.</p>
<p><a href="http://www.david-turner.net/wp-content/uploads/2009/05/image2.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="275" alt="image" src="http://www.david-turner.net/wp-content/uploads/2009/05/image-thumb2.png" width="513" border="0" /></a> </p>
<p>&#160;</p>
<p>I love doing these quick little things that help someone save a lot of time.&#160; </p>
<p>(if you want to use the same stored procedure, here’s the two images we use…</p>
<p>&#160;<a href="http://www.david-turner.net/wp-content/uploads/2009/05/icon-birthday.gif"><img title="icon_birthday" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="19" alt="icon_birthday" src="http://www.david-turner.net/wp-content/uploads/2009/05/icon-birthday-thumb.gif" width="19" border="0" /></a> <a href="http://www.david-turner.net/wp-content/uploads/2009/05/award.jpg"><img title="award" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="23" alt="award" src="http://www.david-turner.net/wp-content/uploads/2009/05/award-thumb.jpg" width="23" border="0" /></a> )</p>
]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2009/05/staff-anniversaries/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Podcast Setup</title>
		<link>http://www.david-turner.net/2009/02/podcast-setup/</link>
		<comments>http://www.david-turner.net/2009/02/podcast-setup/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 18:14:43 +0000</pubDate>
		<dc:creator>David Turner</dc:creator>
				<category><![CDATA[Arena]]></category>

		<guid isPermaLink="false">/post/2009/02/Podcast-Setup.aspx</guid>
		<description><![CDATA[In the interest of possibly helping anyone else set up their podcast, here’s how Arena podcasting is configured in our environment (You can click on any of these images to see them full size).
Feed Formats
Before setting up any channels, you’ll need to setup your available feed formats in the Arena Administration area.
 
XSLT
Arena uses an [...]]]></description>
			<content:encoded><![CDATA[<p>In the interest of possibly helping anyone else set up their podcast, here’s how Arena podcasting is configured in our environment (You can click on any of these images to see them full size).</p>
<h2>Feed Formats</h2>
<p>Before setting up any channels, you’ll need to setup your available feed formats in the Arena Administration area.</p>
<p><a href="http://www.david-turner.net/wp-content/uploads/PodcastFeedFormats.png"><img title="PodcastFeedFormats" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="91" alt="PodcastFeedFormats" src="http://www.david-turner.net/wp-content/uploads/PodcastFeedFormats_thumb.png" width="240" border="0" /></a> </p>
<h2>XSLT</h2>
<p>Arena uses an <em>rss.aspx</em> page to convert an XML version of your feed into a standardized RSS feed format.&#160; This gives you control over fine-tuning how the RSS content is generated (You can view both the XML and the XSLT from the Channel overview page).&#160; Here’s a copy of our <em>xslt/rss/default.xslt</em> file.&#160; This XSLT file creates an RSS feed that is also compliant with iTunes requirements… </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">&lt;?</span><span style="color: #800000">xml</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">=&quot;1.0&quot;</span> <span style="color: #ff0000">encoding</span><span style="color: #0000ff">=&quot;utf-8&quot;</span>?<span style="color: #0000ff">&gt;</span>
<span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:stylesheet</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">=&quot;1.0&quot;</span> <span style="color: #ff0000">xmlns:xsl</span><span style="color: #0000ff">=&quot;http://www.w3.org/1999/XSL/Transform&quot;</span> <span style="color: #ff0000">xmlns:itunes</span><span style="color: #0000ff">=&quot;http://www.itunes.com/dtds/podcast-1.0.dtd&quot;</span><span style="color: #0000ff">&gt;</span>

    <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:output</span> <span style="color: #ff0000">method</span><span style="color: #0000ff">=&quot;xml&quot;</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">=&quot;1.0&quot;</span> <span style="color: #ff0000">encoding</span><span style="color: #0000ff">=&quot;utf-8&quot;</span><span style="color: #0000ff">/&gt;</span>

    <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:template</span> <span style="color: #ff0000">match</span><span style="color: #0000ff">=&quot;/&quot;</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;</span><span style="color: #800000">rss</span> <span style="color: #ff0000">xmlns:itunes</span><span style="color: #0000ff">=&quot;http://www.itunes.com/dtds/podcast-1.0.dtd&quot;</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">=&quot;2.0&quot;</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:for-each</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;/*&quot;</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">channel</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">title</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@author&quot;</span><span style="color: #0000ff">/&gt;</span>: <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@title&quot;</span><span style="color: #0000ff">/&gt;</span> (<span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;format/@title&quot;</span><span style="color: #0000ff">/&gt;</span>)
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">title</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">link</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@link&quot;</span><span style="color: #0000ff">/&gt;</span>
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">link</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">language</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@language&quot;</span><span style="color: #0000ff">/&gt;</span>
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">language</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">copyright</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@copyright&quot;</span><span style="color: #0000ff">/&gt;</span>
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">copyright</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">description</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;description&quot;</span><span style="color: #0000ff">/&gt;</span>
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">description</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">itunes:subtitle</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@subtitle&quot;</span><span style="color: #0000ff">/&gt;</span>
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">itunes:subtitle</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">itunes:author</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@author&quot;</span><span style="color: #0000ff">/&gt;</span>
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">itunes:author</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">itunes:summary</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;description&quot;</span><span style="color: #0000ff">/&gt;</span>
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">itunes:summary</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">itunes:owner</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">itunes:name</span><span style="color: #0000ff">&gt;</span>
                            <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@contactname&quot;</span><span style="color: #0000ff">/&gt;</span>
                        <span style="color: #0000ff">&lt;/</span><span style="color: #800000">itunes:name</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">itunes:email</span><span style="color: #0000ff">&gt;</span>
                            <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@contactemail&quot;</span><span style="color: #0000ff">/&gt;</span>
                        <span style="color: #0000ff">&lt;/</span><span style="color: #800000">itunes:email</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">itunes:owner</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">itunes:image</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:attribute</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;href&quot;</span><span style="color: #0000ff">&gt;</span>
                            <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@imageurl&quot;</span><span style="color: #0000ff">/&gt;</span>
                        <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:attribute</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">itunes:image</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:for-each</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;category&quot;</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:call-template</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;categorynode&quot;</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">xsl:call-template</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:for-each</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:for-each</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;items/item&quot;</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:call-template</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;itemnode&quot;</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">xsl:call-template</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:for-each</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;/</span><span style="color: #800000">channel</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:for-each</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;/</span><span style="color: #800000">rss</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:template</span><span style="color: #0000ff">&gt;</span>

    <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:template</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;categorynode&quot;</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;</span><span style="color: #800000">itunes:category</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:attribute</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;text&quot;</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@text&quot;</span><span style="color: #0000ff">/&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:attribute</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:for-each</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;category&quot;</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:call-template</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;categorynode&quot;</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">xsl:call-template</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:for-each</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;/</span><span style="color: #800000">itunes:category</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:template</span><span style="color: #0000ff">&gt;</span>

    <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:template</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;itemnode&quot;</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;</span><span style="color: #800000">item</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">title</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:choose</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:when</span> <span style="color: #ff0000">test</span><span style="color: #0000ff">=&quot;topic&quot;</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:choose</span><span style="color: #0000ff">&gt;</span>
                            <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:when</span> <span style="color: #ff0000">test</span><span style="color: #0000ff">=&quot;topic/@title = @title&quot;</span><span style="color: #0000ff">&gt;</span>
                                <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@title&quot;</span><span style="color: #0000ff">/&gt;</span>
                            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:when</span><span style="color: #0000ff">&gt;</span>
                            <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:otherwise</span><span style="color: #0000ff">&gt;</span>
                                <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;topic/@title&quot;</span><span style="color: #0000ff">/&gt;</span>: <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@title&quot;</span><span style="color: #0000ff">/&gt;</span>
                            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:otherwise</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:choose</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:when</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:otherwise</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@title&quot;</span><span style="color: #0000ff">/&gt;</span>
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:otherwise</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:choose</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">title</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">pubDate</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@publish&quot;</span><span style="color: #0000ff">/&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">pubDate</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">itunes:author</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;/channel/@author&quot;</span><span style="color: #0000ff">/&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">itunes:author</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:if</span> <span style="color: #ff0000">test</span><span style="color: #0000ff">=&quot;@imageurl&quot;</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">itunes:image</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:attribute</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;href&quot;</span><span style="color: #0000ff">&gt;</span>
                        <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@imageurl&quot;</span><span style="color: #0000ff">/&gt;</span>
                    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:attribute</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;/</span><span style="color: #800000">itunes:image</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:if</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">itunes:summary</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;description&quot;</span><span style="color: #0000ff">/&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">itunes:summary</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">description</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;description&quot;</span><span style="color: #0000ff">/&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">description</span><span style="color: #0000ff">&gt;</span>

            <span style="color: #0000ff">&lt;</span><span style="color: #800000">link</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;@link&quot;</span><span style="color: #0000ff">/&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">link</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">enclosure</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:attribute</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;url&quot;</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;enclosure/@url&quot;</span><span style="color: #0000ff">/&gt;</span>
                <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:attribute</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:attribute</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;length&quot;</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;enclosure/@duration&quot;</span><span style="color: #0000ff">/&gt;</span>
                <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:attribute</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:attribute</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;type&quot;</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;enclosure/@mimetype&quot;</span><span style="color: #0000ff">/&gt;</span>
                <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:attribute</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">enclosure</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">itunes:keywords</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;keywords&quot;</span><span style="color: #0000ff">/&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">itunes:keywords</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:if</span> <span style="color: #ff0000">test</span><span style="color: #0000ff">=&quot;enclosure/@time&quot;</span><span style="color: #0000ff">&gt;</span>
                <span style="color: #0000ff">&lt;</span><span style="color: #800000">itunes:duration</span><span style="color: #0000ff">&gt;</span>
                    <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;enclosure/@time&quot;</span><span style="color: #0000ff">/&gt;</span>
                <span style="color: #0000ff">&lt;/</span><span style="color: #800000">itunes:duration</span><span style="color: #0000ff">&gt;</span>
            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:if</span><span style="color: #0000ff">&gt;</span>
        <span style="color: #0000ff">&lt;/</span><span style="color: #800000">item</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:template</span><span style="color: #0000ff">&gt;</span>

<span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:stylesheet</span><span style="color: #0000ff">&gt;</span></pre>
</div>
<h2>&#160;</h2>
<h2>Arena Page Setup</h2>
<p>Here’s how our Podcasting administrative pages are setup in Arena</p>
<p><a href="http://www.david-turner.net/wp-content/uploads/PodcastAdministrationSetup.png"><img title="PodcastAdministrationSetup" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="214" alt="PodcastAdministrationSetup" src="http://www.david-turner.net/wp-content/uploads/PodcastAdministrationSetup_thumb.png" width="240" border="0" /></a> </p>
<p>The first “Podcast Channels” page simply redirects to the second (not sure why, but that’s how it is).&#160; </p>
<p>The second “Podcast Channels” page has the <strong>ChannelList</strong> module.</p>
<p>The “Channel Details” page has the <strong>ChannelDetail</strong> and <strong>ChannelTabs</strong> (Show Filter setting is set to True) modules.</p>
<p>The “Item Details” page has the <strong>ItemDetail</strong> module.&#160;&#160; <br /><em>Note: I think there’s a bug with the smart page setting on this module.&#160; It’s looking for a page above this one with the <strong>ItemList</strong> module which does not exist.&#160; Our setting points to the Channel Detail page above it.</em></p>
<p>The “Topic Details” page has the <strong>TopicDetail</strong> module.</p>
<p><em>Note: Similar bug here.&#160; It has a smart page setting that looks for a page above this one with the <strong>TopicList</strong> module.&#160; Our setting again points to the Channel Detail page above it.</em></p>
<p>The “Topic Item Detail” page has the <strong>ItemDetail</strong> module.</p>
<p><em>Note: Same bug.&#160; Our Item List Page setting points to the Topic Details page above this page.<br />
    <br /></em>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p>
<h2>Public Pages</h2>
<p>Here’s how the <a href="http://www.ccvonline.com/Arena/default.aspx?Page=12250">public pages</a> on our website are configured…</p>
<h2><a href="http://www.david-turner.net/wp-content/uploads/PodcastWebsiteSetup.png"><img title="PodcastWebsiteSetup" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="84" alt="PodcastWebsiteSetup" src="http://www.david-turner.net/wp-content/uploads/PodcastWebsiteSetup_thumb.png" width="178" border="0" /></a> </h2>
<p>The “Online Message” page in addition to several html modules has the <strong>ChannelView</strong> module. </p>
<p><em>Settings Used: Heading = blank, Image Size = 452, Item View Page = “Message” page below this one, SubHeading = blank, Topic View Page = “Series” page below this one, Use Topic View = True.</em></p>
<p>The “Series” page has the <strong>TopicView</strong> module.</p>
<p><em>Settings Used: Heading = blank, Image Size = 452, Item View Detail Page = “Message” page below this one, SubHeading = blank.</em></p>
<p>The “Message” page has the <strong>ItemFlashViewer</strong> module.</p>
<p>Settings Used: Email Message = blank, Flash Format = Flash Video, Image Size = blank, Object Height = 260, Object Width = 320.</p>
<p>&#160;</p>
<h2>Channel Overview…</h2>
<p>Here’s an example of how our contemporary service podcast is setup.</p>
<p><a href="http://www.david-turner.net/wp-content/uploads/PodcastChannelView.png"><img title="PodcastChannelView" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="239" alt="PodcastChannelView" src="http://www.david-turner.net/wp-content/uploads/PodcastChannelView_thumb.png" width="240" border="0" /></a> </p>
<p>You’ll notice that we use FeedBurner as our external feed so that when people subscribe to the feed they’ll see the FeedBurner url instead of our internal url.&#160; We’ve then configured the Feedburner acount to point back to the actual arena url(<a title="http://arena.ccvonline.com/Arena/rss.aspx?c=1&amp;f=1" href="http://arena.ccvonline.com/Arena/rss.aspx?c=1&amp;f=1">http://arena.ccvonline.com/Arena/rss.aspx?c=1&amp;f=1</a>).</p>
<h2>&#160;</h2>
<h2>Details…</h2>
<p><a href="http://www.david-turner.net/wp-content/uploads/PodcastChannelDetails.png"><img title="PodcastChannelDetails" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="202" alt="PodcastChannelDetails" src="http://www.david-turner.net/wp-content/uploads/PodcastChannelDetails_thumb.png" width="240" border="0" /></a> </p>
<h2>&#160;</h2>
<h2>Enclosure Types…</h2>
<p><a href="http://www.david-turner.net/wp-content/uploads/PodcastChannelEnclosures.png"><img title="PodcastChannelEnclosures" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="90" alt="PodcastChannelEnclosures" src="http://www.david-turner.net/wp-content/uploads/PodcastChannelEnclosures_thumb.png" width="240" border="0" /></a> </p>
<h2>&#160;</h2>
<h2>Topic…</h2>
<p><a href="http://www.david-turner.net/wp-content/uploads/PodcastTopicView.png"><img title="PodcastTopicView" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="266" alt="PodcastTopicView" src="http://www.david-turner.net/wp-content/uploads/PodcastTopicView_thumb.png" width="239" border="0" /></a> </p>
<h2>&#160;</h2>
<h2>Item Overview…</h2>
<p><a href="http://www.david-turner.net/wp-content/uploads/PodcastItemView.png"><img title="PodcastItemView" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="132" alt="PodcastItemView" src="http://www.david-turner.net/wp-content/uploads/PodcastItemView_thumb.png" width="240" border="0" /></a> </p>
<h2>&#160;</h2>
<h2>Item Details…</h2>
<p><a href="http://www.david-turner.net/wp-content/uploads/PodcastTopicDetails.png"><img title="PodcastTopicDetails" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="268" alt="PodcastTopicDetails" src="http://www.david-turner.net/wp-content/uploads/PodcastTopicDetails_thumb.png" width="240" border="0" /></a></p>
</p>
<p>You’ll notice that we use various third-party hosting providers to store our actual video and audio content to cut down on bandwidth to our internal servers.&#160; podcasts.ccvonline.com actually points to an Amazon S3 server.</p>
<p>&#160;</p>
</p>
<p>Hope that helps, comment for any questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2009/02/podcast-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Area Specific Events</title>
		<link>http://www.david-turner.net/2008/06/area-specific-events/</link>
		<comments>http://www.david-turner.net/2008/06/area-specific-events/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 13:37:26 +0000</pubDate>
		<dc:creator>David Turner</dc:creator>
				<category><![CDATA[Arena]]></category>

		<guid isPermaLink="false">/post/2008/06/Area-Specific-Events.aspx</guid>
		<description><![CDATA[You may have noticed that when creating an occurrence in Arena, you can associate it with an area&#8230;.
 
This is useful if you are providing Area specific pages on your web site and you&#8217;d like people to see any events that are occurring for that area, or you&#8217;d like your area leaders be able to [...]]]></description>
			<content:encoded><![CDATA[<p>You may have noticed that when creating an occurrence in Arena, you can associate it with an area&#8230;.</p>
<p><a href="http://www.david-turner.net/wp-content/uploads/WindowsLiveWriter/AreaSpecificEvents_5D16/image_2.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="128" alt="image" src="http://www.david-turner.net/wp-content/uploads/WindowsLiveWriter/AreaSpecificEvents_5D16/image_thumb.png" width="244" border="0"></a> </p>
<p>This is useful if you are providing <a href="http://www.ccvonline.com/Arena/default.aspx?page=11338&amp;area=121">Area specific pages</a> on your web site and you&#8217;d like people to see any events that are occurring for that area, or you&#8217;d like your area leaders be able to add and edit events specific to their area.</p>
<p>The occurrence list module will display all occurrences specific to an area as long as you have the Area Filter Parameter value set&#8230;</p>
<p><a href="http://www.david-turner.net/wp-content/uploads/WindowsLiveWriter/AreaSpecificEvents_5D16/image_4.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="95" alt="image" src="http://www.david-turner.net/wp-content/uploads/WindowsLiveWriter/AreaSpecificEvents_5D16/image_thumb_1.png" width="398" border="0"></a> </p>
<p>This value is what the module will look for on the Query string to determine if it should just display occurrences for a specific area.&nbsp; Because the public Area page has &#8220;area&#8221; in the query string, placing this module on the page will display all occurrences for the current area.</p>
<p>You can also add a link to an area specific list in the Arena application by <a href="http://www.david-turner.net/post/2008/06/Area-quot%3bToolsquot%3b-Tab.aspx">using the Tool tab in the Area Detail page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2008/06/area-specific-events/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Area &#8220;Tools&#8221; Tab</title>
		<link>http://www.david-turner.net/2008/06/area-tools-tab/</link>
		<comments>http://www.david-turner.net/2008/06/area-tools-tab/#comments</comments>
		<pubDate>Fri, 13 Jun 2008 23:31:22 +0000</pubDate>
		<dc:creator>David Turner</dc:creator>
				<category><![CDATA[Arena]]></category>

		<guid isPermaLink="false">/post/2008/06/Area-quot%3bToolsquot%3b-Tab.aspx</guid>
		<description><![CDATA[A cool feature on the Area Details page of Arena is the ability to customize the &#34;Tools&#34; tab to include any HTML that you&#8217;d like.&#160; When editing the settings of the Area Detail module, any HTML that you include in the Details section will be displayed in the Tools tab.
For example, this the HTML that [...]]]></description>
			<content:encoded><![CDATA[<p>A cool feature on the Area Details page of Arena is the ability to customize the &quot;Tools&quot; tab to include any HTML that you&#8217;d like.&#160; When editing the settings of the Area Detail module, any HTML that you include in the Details section will be displayed in the Tools tab.</p>
<p>For example, this the HTML that we&#8217;ve entered for our Area Details module&#8230;</p>
<div>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&lt;div <span style="color: #0000ff">class</span>=<span style="color: #006080">&quot;heading2&quot;</span>&gt;Tools&lt;/div&gt;
&lt;div <span style="color: #0000ff">class</span>=<span style="color: #006080">&quot;normalText&quot;</span> style=<span style="color: #006080">&quot;padding-left:15px&quot;</span>&gt;
    &lt;a href=<span style="color: #006080">'default.aspx?page=1437&amp;Area=&lt;area_id&gt;'</span>&gt;&lt;area_name&gt; Events&lt;/a&gt;&lt;br/&gt;
    &lt;a href=<span style="color: #006080">'default.aspx?page=4065&amp;Area=&lt;area_id&gt;'</span>&gt;View &lt;area_name&gt; Families&lt;/a&gt;&lt;br/&gt;
&lt;/div&gt;
&lt;div <span style="color: #0000ff">class</span>=<span style="color: #006080">&quot;heading2&quot;</span> style=<span style="color: #006080">&quot;padding-top:20px&quot;</span>&gt;Reports&lt;/div&gt;
&lt;div <span style="color: #0000ff">class</span>=<span style="color: #006080">&quot;normalText&quot;</span> style=<span style="color: #006080">&quot;padding-left:20px&quot;</span>&gt;
    &lt;a href=<span style="color: #006080">'default.aspx?page=3987&amp;title=&lt;area_name_encoded&gt; Members, Attenders and Guest Book Signers&amp;AreaID=&lt;area_id&gt;'</span> target=<span style="color: #006080">'_blank'</span>&gt;&lt;area_name&gt; Members, Attenders and Guest Book Signers&lt;/a&gt;&lt;br/&gt;
&lt;/div&gt;</pre>
</div>
<p>As you can see in this example there are some codes you can enter that will be replaced with data from the current Area that is being displayed..</p>
<p>&lt;area_id&gt; will be replaced with the area&#8217;s ID<br />
  <br />&lt;area_name&gt; will be replaced with the area&#8217;s name</p>
<p>&lt;area_name_encoded&gt; will be replaced with a URLEncoded version of the area&#8217;s name.</p>
<p>We use this functionality to link to area specific occurrences (next post), an Area specific person search page (using the AreaPersonFilter module), and to area specific custom reports.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2008/06/area-tools-tab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sample Metric</title>
		<link>http://www.david-turner.net/2008/05/sample-metric/</link>
		<comments>http://www.david-turner.net/2008/05/sample-metric/#comments</comments>
		<pubDate>Mon, 05 May 2008 13:11:48 +0000</pubDate>
		<dc:creator>David Turner</dc:creator>
				<category><![CDATA[Arena]]></category>

		<guid isPermaLink="false">/post/2008/05/Sample-Metric.aspx</guid>
		<description><![CDATA[The Metric functionality in Arena is a very powerful tool for viewing changes in data over time (yes, I know, the UI could still use some improvements).&#160; Essentially it allows you to create any number of metrics by specifying a SQL statement that just returns one numeric value.&#160; Arena will then run that statement how [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.david-turner.net/wp-content/uploads/WindowsLiveWriter/SampleMetric_571E/image_2.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="142" alt="image" src="http://www.david-turner.net/wp-content/uploads/WindowsLiveWriter/SampleMetric_571E/image_thumb.png" width="240" align="right" border="0"></a>The Metric functionality in Arena is a very powerful tool for viewing changes in data over time (yes, I know, the UI could still use some improvements).&nbsp; Essentially it allows you to create any number of metrics by specifying a SQL statement that just returns one numeric value.&nbsp; Arena will then run that statement how ever often you decide, save the result, and chart the values over time.&nbsp; </p>
<p>You can also set up a metric that isn&#8217;t linked to Arena data but instead is hand-entered (i.e. Total Weekend Attendance)</p>
<p>&nbsp;</p>
<h4>Membership Status Metrics</h4>
<p>Since you may not have gotten any sample metrics out of the box, here&#8217;s a SQL script that will add a few for you&#8230;</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">DECLARE</span> @OrganizationID <span style="color: #0000ff">int</span>
<span style="color: #0000ff">SET</span> @OrganizationID = (<span style="color: #0000ff">SELECT</span> <span style="color: #0000ff">TOP</span> 1 organization_id <span style="color: #0000ff">FROM</span> orgn_organization)

<span style="color: #0000ff">DECLARE</span> @AllUsers <span style="color: #0000ff">int</span>
<span style="color: #0000ff">SET</span> @AllUsers = (<span style="color: #0000ff">SELECT</span> <span style="color: #0000ff">TOP</span> 1 role_id <span style="color: #0000ff">FROM</span> secu_role <span style="color: #0000ff">WHERE</span> role_name = <span style="color: #006080">'All Users'</span>)

<span style="color: #0000ff">DECLARE</span> @ParentMetricID <span style="color: #0000ff">int</span>
<span style="color: #0000ff">DECLARE</span> @MetricID <span style="color: #0000ff">int</span>

<span style="color: #008000">-- Create Parent Metric</span>
INSERT <span style="color: #0000ff">INTO</span> [Arena].[dbo].[mtrc_metric]
       ([date_created]
       ,[date_modified]
       ,[created_by]
       ,[modified_by]
       ,[parent_metric_id]
       ,[metric_order]
       ,[graph_type]
       ,[title]
       ,[series_caption]
       ,[description]
       ,[source_summary]
       ,[collection_frequency]
       ,[collection_last_date]
       ,[collection_sql_statement]
       ,[organization_id]
       ,[aggregate_type]
       ,[numeric_x_values])
     <span style="color: #0000ff">VALUES</span>
       (GETDATE()
       ,GETDATE()
       ,<span style="color: #006080">''</span>
       ,<span style="color: #006080">''</span>
       ,<span style="color: #0000ff">NULL</span>
       ,1
       ,-1
       ,<span style="color: #006080">'Membership Status'</span>
       ,<span style="color: #006080">''</span>
       ,<span style="color: #006080">'Metric to show the number of people of each Membership Status over time'</span>
       ,<span style="color: #006080">''</span>
       ,0
       ,<span style="color: #006080">'1/1/1900'</span>
       ,<span style="color: #006080">''</span>
       ,@OrganizationID
       ,<span style="color: #006080">'MAX'</span>
       ,0)    

<span style="color: #0000ff">SET</span> @ParentMetricID = SCOPE_IDENTITY()

INSERT <span style="color: #0000ff">INTO</span> [Arena].[dbo].[secu_permission]
       ([date_created]
       ,[date_modified]
       ,[created_by]
       ,[modified_by]
       ,[object_type]
       ,[operation_type]
       ,[subject_type]
       ,[object_key]
       ,[subject_key])
    <span style="color: #0000ff">VALUES</span>
        (GETDATE()
        ,GETDATE()
        ,<span style="color: #006080">''</span>
        ,<span style="color: #006080">''</span>
        ,6
        ,0
        ,0
        ,@ParentMetricID
        ,@AllUsers )

INSERT <span style="color: #0000ff">INTO</span> [Arena].[dbo].[secu_permission]
       ([date_created]
       ,[date_modified]
       ,[created_by]
       ,[modified_by]
       ,[object_type]
       ,[operation_type]
       ,[subject_type]
       ,[object_key]
       ,[subject_key])
    <span style="color: #0000ff">VALUES</span>
        (GETDATE()
        ,GETDATE()
        ,<span style="color: #006080">''</span>
        ,<span style="color: #006080">''</span>
        ,6
        ,1
        ,0
        ,@ParentMetricID
        ,@AllUsers )

<span style="color: #0000ff">DECLARE</span> @LookupID <span style="color: #0000ff">int</span>
<span style="color: #0000ff">DECLARE</span> @LookupValue <span style="color: #0000ff">varchar</span>(50)
<span style="color: #0000ff">DECLARE</span> @LookupOrder <span style="color: #0000ff">int</span>

<span style="color: #0000ff">DECLARE</span> MemberStatusCursor <span style="color: #0000ff">CURSOR</span> <span style="color: #0000ff">LOCAL</span> <span style="color: #0000ff">FOR</span>
    <span style="color: #0000ff">SELECT</span>
        lookup_id,
        lookup_value,
        lookup_order
    <span style="color: #0000ff">FROM</span> core_lookup L
    <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_lookup_type LT <span style="color: #0000ff">ON</span> LT.lookup_type_id = L.lookup_type_id
    <span style="color: #0000ff">WHERE</span> LT.guid = <span style="color: #006080">'0B4532DB-3188-40F5-B188-E7E6E4448C85'</span>

<span style="color: #0000ff">OPEN</span> MemberStatusCursor

<span style="color: #0000ff">FETCH</span> <span style="color: #0000ff">NEXT</span> <span style="color: #0000ff">FROM</span> MemberStatusCursor
<span style="color: #0000ff">INTO</span> @LookupID, @LookupValue, @LookupOrder

<span style="color: #0000ff">WHILE</span> <span style="color: #cc6633">@@FETCH_STATUS</span> = 0
<span style="color: #0000ff">BEGIN</span>

    INSERT <span style="color: #0000ff">INTO</span> [Arena].[dbo].[mtrc_metric]
           ([date_created]
           ,[date_modified]
           ,[created_by]
           ,[modified_by]
           ,[parent_metric_id]
           ,[metric_order]
           ,[graph_type]
           ,[title]
           ,[series_caption]
           ,[description]
           ,[source_summary]
           ,[collection_frequency]
           ,[collection_last_date]
           ,[collection_sql_statement]
           ,[organization_id]
           ,[aggregate_type]
           ,[numeric_x_values])
        <span style="color: #0000ff">VALUES</span>
           (GETDATE()
           ,GETDATE()
           ,<span style="color: #006080">''</span>
           ,<span style="color: #006080">''</span>
           ,@ParentMetricID
           ,@LookupOrder
           ,0
           ,<span style="color: #006080">'Number of '</span> + @LookupValue + <span style="color: #006080">'s'</span>
           ,@LookupValue + <span style="color: #006080">'s'</span>
           ,<span style="color: #006080">'Number of people classifed as "'</span> + @LookupValue + <span style="color: #006080">'"'</span>
           ,<span style="color: #006080">''</span>
           ,2
           ,GETDATE()
           ,<span style="color: #006080">'SELECT COUNT(*) AS people_count FROM Arena.dbo.core_person WHERE record_status = 0 AND member_status = '</span> + <span style="color: #0000ff">CAST</span>(@LookupID <span style="color: #0000ff">as</span> <span style="color: #0000ff">varchar</span>)
           ,@OrganizationID
           ,<span style="color: #006080">'MAX'</span>
           ,0)

    <span style="color: #0000ff">SET</span> @MetricID = SCOPE_IDENTITY()

    INSERT <span style="color: #0000ff">INTO</span> [Arena].[dbo].[secu_permission]
           ([date_created]
           ,[date_modified]
           ,[created_by]
           ,[modified_by]
           ,[object_type]
           ,[operation_type]
           ,[subject_type]
           ,[object_key]
           ,[subject_key])
        <span style="color: #0000ff">VALUES</span>
            (GETDATE()
            ,GETDATE()
            ,<span style="color: #006080">''</span>
            ,<span style="color: #006080">''</span>
            ,6
            ,0
            ,0
            ,@MetricID
            ,@AllUsers )

    INSERT <span style="color: #0000ff">INTO</span> [Arena].[dbo].[secu_permission]
           ([date_created]
           ,[date_modified]
           ,[created_by]
           ,[modified_by]
           ,[object_type]
           ,[operation_type]
           ,[subject_type]
           ,[object_key]
           ,[subject_key])
        <span style="color: #0000ff">VALUES</span>
            (GETDATE()
            ,GETDATE()
            ,<span style="color: #006080">''</span>
            ,<span style="color: #006080">''</span>
            ,6
            ,1
            ,0
            ,@MetricID
            ,@AllUsers )

    <span style="color: #0000ff">FETCH</span> <span style="color: #0000ff">NEXT</span> <span style="color: #0000ff">FROM</span> MemberStatusCursor
    <span style="color: #0000ff">INTO</span> @LookupID, @LookupValue, @LookupOrder

<span style="color: #0000ff">END</span>

<span style="color: #0000ff">CLOSE</span> MemberStatusCursor
<span style="color: #0000ff">DEALLOCATE</span> MemberStatusCursor
</pre>
</div>
<p>Running this script will create a parent &#8220;Membership Status&#8221; metric and then a child metric for each Member Status you&#8217;ve defined (and grants the &#8220;All Users&#8221; role view and edit permissions). </p>
<p>Each of the child metrics will chart the number of people of that member status over time.&nbsp; As long as the ArenaProcessMetrics agent is running, you will see a chart after it&#8217;s collected the metrics data twice (two weeks from now). </p>
<p>&nbsp;</p>
<h4>Historical Data</h4>
<p>If you don&#8217;t want to wait two weeks to see your data and/or you want to see all your historical member status data up to this point, we can use the core_member_status_history table to generate historical membership status data for your metrics&#8230;</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">SET</span> NOCOUNT <span style="color: #0000ff">ON</span>
<span style="color: #0000ff">GO</span>

<span style="color: #0000ff">DECLARE</span> @ParentMetricID <span style="color: #0000ff">int</span>
<span style="color: #0000ff">DECLARE</span> @MinHistoryDate datetime
<span style="color: #0000ff">DECLARE</span> @WorkingDate datetime
<span style="color: #0000ff">DECLARE</span> @Status <span style="color: #0000ff">varchar</span>(15)

<span style="color: #0000ff">SET</span> @ParentMetricID = (<span style="color: #0000ff">SELECT</span> <span style="color: #0000ff">MAX</span>(metric_id) <span style="color: #0000ff">FROM</span> mtrc_metric <span style="color: #0000ff">WHERE</span> title = <span style="color: #006080">'Membership Status'</span> <span style="color: #0000ff">AND</span> parent_metric_id <span style="color: #0000ff">IS</span> <span style="color: #0000ff">NULL</span>)
<span style="color: #0000ff">SET</span> @MinHistoryDate = (<span style="color: #0000ff">SELECT</span> <span style="color: #0000ff">MIN</span>(date_created) <span style="color: #0000ff">FROM</span> core_member_status_history)
<span style="color: #0000ff">SET</span> @WorkingDate = GETDATE()

<span style="color: #0000ff">DELETE</span> mtrc_metric_item
<span style="color: #0000ff">FROM</span> mtrc_metric_item MI
<span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> mtrc_metric M <span style="color: #0000ff">ON</span> M.metric_id = MI.metric_id
<span style="color: #0000ff">WHERE</span> M.parent_metric_id = @ParentMetricID

<span style="color: #0000ff">WHILE</span> @MinHistoryDate <span style="color: #0000ff">IS</span> <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>
<span style="color: #0000ff">AND</span> @WorkingDate &gt; @MinHistoryDate
<span style="color: #0000ff">BEGIN</span>

    <span style="color: #0000ff">SET</span> @Status = <span style="color: #0000ff">CONVERT</span>(<span style="color: #0000ff">varchar</span>(10), @WorkingDate, 101) + <span style="color: #006080">'...'</span>
    <span style="color: #0000ff">RAISERROR</span> (@Status, 0, 1) <span style="color: #0000ff">WITH</span> NOWAIT;

    <span style="color: #0000ff">WITH</span> memberStatusTable (person_id, member_status)
    <span style="color: #0000ff">AS</span>
    (
        <span style="color: #0000ff">SELECT</span>
            person_id,
            ISNULL((<span style="color: #0000ff">SELECT</span> <span style="color: #0000ff">TOP</span> 1 member_status
                <span style="color: #0000ff">FROM</span> core_member_status_history
                <span style="color: #0000ff">WHERE</span> person_id = P.person_id
                <span style="color: #0000ff">AND</span> date_created &lt; @WorkingDate
                <span style="color: #0000ff">ORDER</span> <span style="color: #0000ff">BY</span> date_created <span style="color: #0000ff">DESC</span>), p.member_status) <span style="color: #0000ff">AS</span> member_status
        <span style="color: #0000ff">FROM</span> core_person P
        <span style="color: #0000ff">WHERE</span> date_created &lt;= @WorkingDate
    )

    INSERT <span style="color: #0000ff">INTO</span> mtrc_metric_item
    <span style="color: #0000ff">SELECT</span>
         GETDATE()
        ,GETDATE()
        ,<span style="color: #006080">''</span>
        ,<span style="color: #006080">''</span>
        ,M.metric_id
        ,(<span style="color: #0000ff">SELECT</span> <span style="color: #0000ff">COUNT</span>(*)
            <span style="color: #0000ff">FROM</span> memberStatusTable
            <span style="color: #0000ff">WHERE</span> member_status = L.lookup_id)
        ,@WorkingDate
        ,<span style="color: #006080">''</span>
        ,0
    <span style="color: #0000ff">FROM</span> core_lookup L
    <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> core_lookup_type LT
        <span style="color: #0000ff">ON</span> LT.lookup_type_id = L.lookup_type_id
    <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> mtrc_metric M
        <span style="color: #0000ff">ON</span> M.title = <span style="color: #006080">'Number of '</span> + L.lookup_value + <span style="color: #006080">'s'</span>
        <span style="color: #0000ff">AND</span> M.parent_metric_id = @ParentMetricID
    <span style="color: #0000ff">WHERE</span> LT.guid = <span style="color: #006080">'0B4532DB-3188-40F5-B188-E7E6E4448C85'</span>

    <span style="color: #0000ff">SET</span> @WorkingDate = DATEADD(wk, -1, @WorkingDate)

<span style="color: #0000ff">END</span>
</pre>
</div>
<p>This script will create data for the metrics you created above for as far back as you have data in the core_member_status_history table.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2008/05/sample-metric/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
