<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Selecting the MODE of a group of data in Microsoft Access</title>
	<link>http://ask.metafilter.com/53121/Selecting-the-MODE-of-a-group-of-data-in-Microsoft-Access/</link>
	<description>Comments on Ask MetaFilter post Selecting the MODE of a group of data in Microsoft Access</description>
	<pubDate>Thu, 14 Dec 2006 04:28:28 -0800</pubDate>
	<lastBuildDate>Thu, 14 Dec 2006 04:28:28 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Selecting the MODE of a group of data in Microsoft Access</title>
		<link>http://ask.metafilter.com/53121/Selecting-the-MODE-of-a-group-of-data-in-Microsoft-Access</link>	
		<description>Microsoft Access.  An SQL &quot;GROUP BY&quot; query.  How do I generate the &lt;i&gt;mode&lt;/i&gt; of the values that it&apos;s grouping, when I want averages in other multiple fields? &lt;br /&gt;&lt;br /&gt; I&apos;m trying to query an Access database, grouping by a field, and I need a variety of operations performed on the other fields that it&apos;s grouping.  Some of them (numerical data) I need an average, which is easy.  Other fields (categorical data) I need it to give me the mode, or most common value, because an average doesn&apos;t make sense.&lt;br&gt;
&lt;br&gt;
Searching for an answer, I&apos;ve found a way to do it using a:&lt;br&gt;
&lt;code&gt;&lt;br&gt;
SELECT TOP 1 data, COUNT(*) Count&lt;br&gt;
FROM [table]&lt;br&gt;
GROUP BY data&lt;br&gt;
ORDER BY Count DESC &lt;br&gt;
&lt;/code&gt;&lt;br&gt;
query, but this only seems to work if you&apos;re working on a single field, not multiple fields that need different things done to them.  What&apos;s the simplest way of doing this, short of writing a query for &lt;i&gt;every&lt;/i&gt; field separately, then joining all the output tables back together?</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2006:site.53121</guid>
		<pubDate>Wed, 13 Dec 2006 23:04:29 -0800</pubDate>
		<dc:creator>Jimbob</dc:creator>
		
			<category>sql</category>
		
			<category>database</category>
		
			<category>microsoft</category>
		
			<category>access</category>
		
			<category>query</category>
		
			<category>mode</category>
		
			<category>average</category>
		
	</item> <item>
		<title>By: ParsonWreck</title>
		<link>http://ask.metafilter.com/53121/Selecting-the-MODE-of-a-group-of-data-in-Microsoft-Access#800991</link>	
		<description>The example you gave &lt;b&gt;is&lt;/b&gt; the simplest way to do it in straight SQL. SQL has some noticeable shortcomings when it comes to statistics.&lt;br&gt;
&lt;br&gt;
You can probably simplify the query&apos;s &lt;i&gt;appearance&lt;/i&gt; with a function to calculate the mode of a field, and use separate subqueries for the averages and modes. But the database will still perform the same amount of work. &lt;br&gt;
&lt;br&gt;
Something like: &lt;br&gt;
&lt;code&gt;SELECT T1.*, T2.*&lt;br&gt;
FROM&lt;br&gt;
&#160;&#160;(SELECT col1, AVG(col2) as col2Average, AVG(col3) as col3Average&lt;br&gt;
&#160;&#160;&#160;FROM [table1]&lt;br&gt;
&#160;&#160;&#160;GROUP BY col1) as T1,&lt;br&gt;
&#160;&#160;(SELECT fn_Mode(&apos;table1&apos;, &apos;col4&apos;) as col4Mode, fn_Mode(&apos;table1&apos;, &apos;col5&apos;) as col5Mode&lt;br&gt;
&#160;&#160;&#160;FROM [table]) as T2&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Where the fn_Mode() function just implements the example query you gave.&lt;br&gt;
&lt;br&gt;
(Note: I haven&apos;t coded in Access for a few years, so the subqueries there might not work as written. You might have to create separate views for each ... but hopefully you get the idea.)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.53121-800991</guid>
		<pubDate>Thu, 14 Dec 2006 04:28:28 -0800</pubDate>
		<dc:creator>ParsonWreck</dc:creator>
	</item><item>
		<title>By: ParsonWreck</title>
		<link>http://ask.metafilter.com/53121/Selecting-the-MODE-of-a-group-of-data-in-Microsoft-Access#801001</link>	
		<description>(That &lt;code&gt;FROM [table]&lt;/code&gt; in T2 shouldn&apos;t be there.)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.53121-801001</guid>
		<pubDate>Thu, 14 Dec 2006 04:44:26 -0800</pubDate>
		<dc:creator>ParsonWreck</dc:creator>
	</item><item>
		<title>By: owhydididoit</title>
		<link>http://ask.metafilter.com/53121/Selecting-the-MODE-of-a-group-of-data-in-Microsoft-Access#801624</link>	
		<description>If your data only comes from one table, you should consider exporting it to Excel, and doing your statistical analysis there. Excel offers the MODE function that you seek.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.53121-801624</guid>
		<pubDate>Thu, 14 Dec 2006 14:47:01 -0800</pubDate>
		<dc:creator>owhydididoit</dc:creator>
	</item>
	</channel>
</rss>
