<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PMA Media Group&#187; sql</title>
	<atom:link href="http://www.pmamediagroup.com/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pmamediagroup.com</link>
	<description>Unique Marketing Techniques and Strategies with Guaranteed Results!</description>
	<lastBuildDate>Thu, 29 Jul 2010 15:34:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>You Don&#8217;t Need Custom SQL For Simple Aggregation Using ActiveRecord</title>
		<link>http://www.pmamediagroup.com/2009/04/you-dont-need-custom-sql-for-simple-aggregation-using-activerecord/</link>
		<comments>http://www.pmamediagroup.com/2009/04/you-dont-need-custom-sql-for-simple-aggregation-using-activerecord/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 19:36:04 +0000</pubDate>
		<dc:creator>Aaron Murphy</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[average]]></category>
		<category><![CDATA[count]]></category>
		<category><![CDATA[maximum]]></category>
		<category><![CDATA[minimum]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sum]]></category>

		<guid isPermaLink="false">http://www.pmamediagroup.com/?p=195</guid>
		<description><![CDATA[ActiveRecord allows one to execute an SQL statement directly. I prefer to avoid any ActiveRecord code that uses too much SQL syntax. This way I won&#8217;t have to rework any code if the underlying database engine was changed.  Some of the simple SQL functions that one may want to do with SQL syntax might [...]]]></description>
			<content:encoded><![CDATA[<p>ActiveRecord allows one to execute an SQL statement directly. I prefer to avoid any ActiveRecord code that uses too much SQL syntax. This way I won&#8217;t have to rework any code if the underlying database engine was changed.  Some of the simple SQL functions that one may want to do with SQL syntax might be SUM, AVG, COUNT, etc. With <a href="http://api.rubyonrails.org/classes/ActiveRecord/Calculations/ClassMethods.html">ActiveRecord::Calculations::ClassMethods</a>, one can avoid specialized syntax.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#returns the total count of all people</span>
Person.<span style="color:#9900CC;">count</span>
<span style="color:#008000; font-style:italic;"># returns the total count of all people with an age over 26</span>
Person.<span style="color:#9900CC;">count</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;age &gt; 26&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>The following methods are available: <strong>average, count, maximum, minimum, sum</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pmamediagroup.com/2009/04/you-dont-need-custom-sql-for-simple-aggregation-using-activerecord/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/


Served from: www.pmamediagroup.com @ 2010-07-31 10:57:03 -->