<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>David Turner</title>
	
	<link>http://www.david-turner.net</link>
	<description>...Developing Software for the Church</description>
	<lastBuildDate>Fri, 11 Nov 2011 17:24:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/david-turner/Mrsq" /><feedburner:info uri="david-turner/mrsq" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Assignment Types Performance</title>
		<link>http://feedproxy.google.com/~r/david-turner/Mrsq/~3/nAkru96VCkg/</link>
		<comments>http://www.david-turner.net/2010/10/assignment-types-performance/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 23:13:06 +0000</pubDate>
		<dc:creator>David Turner</dc:creator>
				<category><![CDATA[Arena]]></category>

		<guid isPermaLink="false">http://www.david-turner.net/2010/10/assignment-types-performance/</guid>
		<description><![CDATA[I mentioned improving performance in Arena Assignment Types during my RefreshCache presentation.  It was actually just a stored procedure change.  Here’s the change if you’d like to see if it helps your performance… &#160; ALTER PROC [dbo].[asgn_sp_get_assignmentTypeList] &#160; ( &#160; @ParentAssignmentTypeID int &#160; , @PersonID int &#160; ) &#160; AS &#160; &#160; DECLARE @hierarchy TABLE [...]]]></description>
			<content:encoded><![CDATA[<p>I mentioned improving performance in Arena Assignment Types during my RefreshCache presentation.  It was actually just a stored procedure change.  Here’s the change if you’d like to see if it helps your performance…</p>
<p>&nbsp;</p>
<div id="codeSnippetWrapper" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">ALTER</span> <span style="color: #0000ff;">PROC</span> [dbo].[asgn_sp_get_assignmentTypeList]</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">(</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    @ParentAssignmentTypeID <span style="color: #0000ff;">int</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , @PersonID <span style="color: #0000ff;">int</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">AS</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">DECLARE</span> @hierarchy <span style="color: #0000ff;">TABLE</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">(</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">      assignment_type_id <span style="color: #0000ff;">int</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , root_assignment_type_id <span style="color: #0000ff;">int</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , total_types <span style="color: #0000ff;">int</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , total_assignments <span style="color: #0000ff;">int</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , active_assignments <span style="color: #0000ff;">int</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , pastdue_assignments <span style="color: #0000ff;">int</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">);</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">with</span> AssignmentTypeHierarchy</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">as</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">(</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #008000;">-- root</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">select</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">          assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        , root_assignment_type_id = <span style="color: #0000ff;">NULL</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">from</span> asgn_assignment_type t <span style="color: #0000ff;">WITH</span>(NOLOCK)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">where</span> isnull(t.parent_assignment_type_id, -1) = @ParentAssignmentTypeID</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">union</span> <span style="color: #0000ff;">all</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #008000;">-- recursive part</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">select</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">          t.assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        , root_assignment_type_id =</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">case</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">                <span style="color: #0000ff;">when</span> ath.root_assignment_type_id <span style="color: #0000ff;">is</span> <span style="color: #0000ff;">null</span> <span style="color: #0000ff;">then</span> ath.assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">                <span style="color: #0000ff;">else</span> ath.root_assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">end</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">from</span> asgn_assignment_type t <span style="color: #0000ff;">WITH</span>(NOLOCK)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">inner</span> <span style="color: #0000ff;">join</span> AssignmentTypeHierarchy ath <span style="color: #0000ff;">on</span> t.parent_assignment_type_id = ath.assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">INSERT <span style="color: #0000ff;">INTO</span> @hierarchy</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">(</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">      assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , root_assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , total_types</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , total_assignments</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , active_assignments</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , pastdue_assignments</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">SELECT</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">      assignment_type_id = ath.assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , root_assignment_type_id = ath.root_assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , total_types =</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        (</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">SELECT</span> <span style="color: #0000ff;">COUNT</span>(*)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">FROM</span> asgn_assignment_type t2 <span style="color: #0000ff;">WITH</span>(NOLOCK)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">WHERE</span> t2.parent_assignment_type_id = ath.assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        )</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , total_assignments =</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        (</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">SELECT</span> <span style="color: #0000ff;">COUNT</span>(*)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">FROM</span> asgn_assignment a <span style="color: #0000ff;">WITH</span>(NOLOCK)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">WHERE</span> a.assignment_type_id = ath.assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        )</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , active_assignments =</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        (</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">SELECT</span> <span style="color: #0000ff;">COUNT</span>(*)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">FROM</span> asgn_assignment a <span style="color: #0000ff;">WITH</span>(NOLOCK)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">WHERE</span> a.assignment_type_id = ath.assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">AND</span> a.active = 1</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        )</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , pastdue_assignments =</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        (</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">SELECT</span> <span style="color: #0000ff;">COUNT</span>(*)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">FROM</span> asgn_assignment a <span style="color: #0000ff;">WITH</span>(NOLOCK)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">WHERE</span> a.assignment_type_id = ath.assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">AND</span> a.active = 1</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">AND</span> a.due_date &lt;&gt; <span style="color: #006080;">'1/1/1900'</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">AND</span> DATEDIFF(d, a.due_date, GETDATE()) &gt; 0</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        )</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">FROM</span> AssignmentTypeHierarchy ath</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">SELECT</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">      t.*</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , assignment_type_count =</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        (</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            ISNULL((<span style="color: #0000ff;">SELECT</span> <span style="color: #0000ff;">SUM</span>(total_types)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">FROM</span> @hierarchy h</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">WHERE</span> (h.root_assignment_type_id = t.assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">                <span style="color: #0000ff;">OR</span> h.assignment_type_id = t.assignment_type_id )), 0)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        )</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , disable_delete =</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        <span style="color: #0000ff;">CASE</span> <span style="color: #0000ff;">WHEN</span> (</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">                ISNULL((<span style="color: #0000ff;">SELECT</span> <span style="color: #0000ff;">SUM</span>(total_assignments)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">                <span style="color: #0000ff;">FROM</span> @hierarchy h</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">                <span style="color: #0000ff;">WHERE</span> (h.root_assignment_type_id = t.assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">                    <span style="color: #0000ff;">OR</span> h.assignment_type_id = t.assignment_type_id )), 0)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">                ) &gt; 0</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">THEN</span> <span style="color: #0000ff;">convert</span>(<span style="color: #0000ff;">bit</span>, 1)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">ELSE</span> <span style="color: #0000ff;">convert</span>(<span style="color: #0000ff;">bit</span>, 0) <span style="color: #0000ff;">END</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , assignment_count =</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        (</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            ISNULL((<span style="color: #0000ff;">SELECT</span> <span style="color: #0000ff;">SUM</span>(total_assignments)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">FROM</span> @hierarchy h</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">WHERE</span> (h.root_assignment_type_id = t.assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">                <span style="color: #0000ff;">OR</span> h.assignment_type_id = t.assignment_type_id )), 0)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        )</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , assignment_active_count =</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        (</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            ISNULL((<span style="color: #0000ff;">SELECT</span> <span style="color: #0000ff;">SUM</span>(active_assignments)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">FROM</span> @hierarchy h</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">WHERE</span> (h.root_assignment_type_id = t.assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">                <span style="color: #0000ff;">OR</span> h.assignment_type_id = t.assignment_type_id )), 0)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        )</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , assignment_pastdue_count =</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        (</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            ISNULL((<span style="color: #0000ff;">SELECT</span> <span style="color: #0000ff;">SUM</span>(pastdue_assignments)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">FROM</span> @hierarchy h</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">WHERE</span> (h.root_assignment_type_id = t.assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">                <span style="color: #0000ff;">OR</span> h.assignment_type_id = t.assignment_type_id )), 0)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        )</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , subscribed =</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        <span style="color: #0000ff;">case</span> <span style="color: #0000ff;">when</span> s.assignment_type_id <span style="color: #0000ff;">is</span> <span style="color: #0000ff;">not</span> <span style="color: #0000ff;">null</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">then</span> <span style="color: #0000ff;">convert</span>(<span style="color: #0000ff;">bit</span>, 1)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">            <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">convert</span>(<span style="color: #0000ff;">bit</span>, 0)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">        <span style="color: #0000ff;">end</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , owner_name = p.last_name + <span style="color: #006080;">', '</span> + <span style="color: #0000ff;">CASE</span> <span style="color: #0000ff;">WHEN</span> LEN(p.nick_name) = 0 <span style="color: #0000ff;">THEN</span> p.first_name <span style="color: #0000ff;">ELSE</span> p.nick_name <span style="color: #0000ff;">END</span></pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , owner_guid = p.guid</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    , owner_blob_id = p.blob_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">from</span> asgn_assignment_type t <span style="color: #0000ff;">WITH</span>(NOLOCK)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">left</span> <span style="color: #0000ff;">outer</span> <span style="color: #0000ff;">join</span> core_person p <span style="color: #0000ff;">WITH</span>(NOLOCK)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">on</span> t.owner_person_id = p.person_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">left</span> <span style="color: #0000ff;">outer</span> <span style="color: #0000ff;">join</span> asgn_assignment_type_subscribe s <span style="color: #0000ff;">WITH</span>(NOLOCK)</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">on</span> s.assignment_type_id = t.assignment_type_id</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">    <span style="color: #0000ff;">and</span> s.person_id = @PersonID</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">where</span> isnull(t.parent_assignment_type_id, -1) = @ParentAssignmentTypeID</pre>
<p>&nbsp;</p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff;">order</span> <span style="color: #0000ff;">by</span> t.assignment_order</pre>
<p>&nbsp;</p>
</div>
</div>
<p>&nbsp;</p>
<p>DISCLAIMER: Install at your own risk, and keep in mind that it will be overwritten on an Arena upgrade.</p>
<img src="http://feeds.feedburner.com/~r/david-turner/Mrsq/~4/nAkru96VCkg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2010/10/assignment-types-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.david-turner.net/2010/10/assignment-types-performance/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=assignment-types-performance</feedburner:origLink></item>
		<item>
		<title>Alerts</title>
		<link>http://feedproxy.google.com/~r/david-turner/Mrsq/~3/VUZbtpxbOjE/</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>
<img src="http://feeds.feedburner.com/~r/david-turner/Mrsq/~4/VUZbtpxbOjE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2010/03/alerts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.david-turner.net/2010/03/alerts/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=alerts</feedburner:origLink></item>
		<item>
		<title>eRA</title>
		<link>http://feedproxy.google.com/~r/david-turner/Mrsq/~3/3fC1w9_GQNM/</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 [...]]]></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>
<img src="http://feeds.feedburner.com/~r/david-turner/Mrsq/~4/3fC1w9_GQNM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2009/10/era/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.david-turner.net/2009/10/era/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=era</feedburner:origLink></item>
		<item>
		<title>Aggregate Type</title>
		<link>http://feedproxy.google.com/~r/david-turner/Mrsq/~3/hi7W-DQXerE/</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. [...]]]></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>
<img src="http://feeds.feedburner.com/~r/david-turner/Mrsq/~4/hi7W-DQXerE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2009/09/aggregate-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.david-turner.net/2009/09/aggregate-type/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=aggregate-type</feedburner:origLink></item>
		<item>
		<title>“Regular” Attendees</title>
		<link>http://feedproxy.google.com/~r/david-turner/Mrsq/~3/ILQzAGo9_m8/</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>
<img src="http://feeds.feedburner.com/~r/david-turner/Mrsq/~4/ILQzAGo9_m8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2009/08/regular-attendees/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.david-turner.net/2009/08/regular-attendees/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=regular-attendees</feedburner:origLink></item>
		<item>
		<title>A New Blog</title>
		<link>http://feedproxy.google.com/~r/david-turner/Mrsq/~3/w_N7fzisQvg/</link>
		<comments>http://www.david-turner.net/2009/07/a-new-blog/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 14:46:17 +0000</pubDate>
		<dc:creator>David Turner</dc:creator>
				<category><![CDATA[Family]]></category>

		<guid isPermaLink="false">http://www.david-turner.net/2009/07/a-new-blog/</guid>
		<description><![CDATA[I’ve decided to create a new blog for the family/personal side of things.&#160; Mixing work (Arena, CCV) and family stuff on the same blog just hasn’t been working for me.&#160; They say you need to know your audience, and I really have two completely different audiences reading this blog, so I find myself not posting [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve decided to create a new blog for the family/personal side of things.&#160; Mixing work (<a href="http://www.arenachms.com" target="_blank">Arena</a>, <a href="http://www.ccvonline.com" target="_blank">CCV</a>) and family stuff on the same blog just hasn’t been working for me.&#160; They say you need to know your audience, and I really have two completely different audiences reading this blog, so I find myself not posting at all because anything I’d post has no relevance to half the people reading.</p>
<p>So, for all of you that really have no interest in the latest Arena tip, or module, or what I’m working on at CCV… stop reading this blog, and head over to <a href="http://www.azturners.com">www.azturners.com</a>.&#160; We’re getting close to Hannah’s brain surgery, and I will probably be posting more on the <a href="http://www.azturners.com" target="_blank">azturners</a> site over the next several weeks.&#160; I’ve also moved all my family related posts (and comments) from this site over to the azturners site.</p>
<p>So stay tuned here if your interested in my work with Arena, CCV, etc.</p>
<img src="http://feeds.feedburner.com/~r/david-turner/Mrsq/~4/w_N7fzisQvg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2009/07/a-new-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.david-turner.net/2009/07/a-new-blog/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=a-new-blog</feedburner:origLink></item>
		<item>
		<title>Arena as a CMS</title>
		<link>http://feedproxy.google.com/~r/david-turner/Mrsq/~3/lU09_ydQMig/</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, [...]]]></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>
<img src="http://feeds.feedburner.com/~r/david-turner/Mrsq/~4/lU09_ydQMig" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2009/06/arena-as-a-cms/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.david-turner.net/2009/06/arena-as-a-cms/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=arena-as-a-cms</feedburner:origLink></item>
		<item>
		<title>Staff Anniversaries</title>
		<link>http://feedproxy.google.com/~r/david-turner/Mrsq/~3/BUywWIljucg/</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>
<img src="http://feeds.feedburner.com/~r/david-turner/Mrsq/~4/BUywWIljucg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2009/05/staff-anniversaries/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://www.david-turner.net/2009/05/staff-anniversaries/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=staff-anniversaries</feedburner:origLink></item>
		<item>
		<title>Can You See Me Now?</title>
		<link>http://feedproxy.google.com/~r/david-turner/Mrsq/~3/vnTZEowAFjY/</link>
		<comments>http://www.david-turner.net/2009/05/can-you-see-me-now/#comments</comments>
		<pubDate>Sat, 23 May 2009 19:28:56 +0000</pubDate>
		<dc:creator>David Turner</dc:creator>
				<category><![CDATA[CCV]]></category>

		<guid isPermaLink="false">http://www.david-turner.net/?p=94</guid>
		<description><![CDATA[Not sure anyone is going to see this post, since I moved and didn’t tell anyone. Why? I wanted a new blog.&#160; I wasn’t thrilled by how dated my old blog looked, and I think I’m also going to try and write more often (let’s say… oh… at least once a week).&#160; Figured I’d clean [...]]]></description>
			<content:encoded><![CDATA[<p>Not sure anyone is going to see this post, since I moved and didn’t tell anyone.</p>
<h3>Why?</h3>
<p>I wanted a new blog.&#160; I wasn’t thrilled by how dated my old blog looked, and I think I’m also going to try and write more often (let’s say… oh… at least once a week).&#160; Figured I’d clean it up first, so I ditched my old BlogEngine.NET blog hosted at GoDaddy, and went with a WordPress blog hosted at Dreamhost (all my friends we’re doing it).</p>
<p>I did update the nameservers for my domain, but because of differences between the WordPress feed and the old feed, and because of some strange things happening in my FeedBurner account, I’m pretty sure I’m writing this post only for me.&#160; But… If I’m wrong, and you see me, say hello.</p>
<h3>What’s Different?</h3>
<p>I was challenged by my friend <strike>and fellow blogger</strike> Erik, to include more posts about me (you know real-world stuff) and not just stuff about <a href="http://www.arenachms.com" target="_blank">Arena</a>.&#160; So while I will keep posting things about Arena (and other work stuff), I’ll also try and add some things about what captivates me when I’m not at my day job.</p>
<h3>And That Is?</h3>
<p>So what captivates me when I’m not at work.&#160; Well… I have a 16 year old son who hasn’t quite got his license yet, but works a lot as a Lifeguard and is big into dirt bikes, so I spend&#160; a great deal of my time driving him around and hanging out with him at the dirt track.&#160; My 10 year old daughter has Refractory Epilepsy so we’re trying to manage her 10+ seizures a day and considering the alternatives for her treatment (surgery).&#160; She still is my best movie partner as we seem to be the only two in the family who really enjoy intense action movies.&#160; My 7 year old son is autistic (high functioning), and is my biggest helper.&#160; Him and I are the two morning people and are often long at work in the yard together before anyone else is even up.&#160; And of course my wife.&#160; She helps me to survive it all.</p>
<p>Wow… that kinda felt like I was filling out an online dating ad (good thing no one is reading it anyway).&#160; Next post is going to be about Arena.</p>
<img src="http://feeds.feedburner.com/~r/david-turner/Mrsq/~4/vnTZEowAFjY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2009/05/can-you-see-me-now/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.david-turner.net/2009/05/can-you-see-me-now/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=can-you-see-me-now</feedburner:origLink></item>
		<item>
		<title>Podcast Setup</title>
		<link>http://feedproxy.google.com/~r/david-turner/Mrsq/~3/zUF_UEVSyDg/</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 [...]]]></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>
<img src="http://feeds.feedburner.com/~r/david-turner/Mrsq/~4/zUF_UEVSyDg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.david-turner.net/2009/02/podcast-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.david-turner.net/2009/02/podcast-setup/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=podcast-setup</feedburner:origLink></item>
	</channel>
</rss>

