<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://sqlzoo.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://sqlzoo.net/w/index.php?title=No_Group_By_Function&amp;feed=atom&amp;action=history</id>
		<title>No Group By Function - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://sqlzoo.net/w/index.php?title=No_Group_By_Function&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=No_Group_By_Function&amp;action=history"/>
		<updated>2013-05-24T14:10:17Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.20.4</generator>

	<entry>
		<id>http://sqlzoo.net/w/index.php?title=No_Group_By_Function&amp;diff=3377&amp;oldid=prev</id>
		<title>Andr3w at 13:20, 9 August 2012</title>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=No_Group_By_Function&amp;diff=3377&amp;oldid=prev"/>
				<updated>2012-08-09T13:20:27Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 13:20, 9 August 2012&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 29:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 29:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;ecomm e-access&amp;quot; style=&amp;quot;display: none&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;ecomm e-access&amp;quot; style=&amp;quot;display: none&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Error]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Andr3w</name></author>	</entry>

	<entry>
		<id>http://sqlzoo.net/w/index.php?title=No_Group_By_Function&amp;diff=1889&amp;oldid=prev</id>
		<title>Connor: Created page with &quot;&lt;div class='err'&gt; &lt;div class=params&gt;schema:gisq&lt;/div&gt; &lt;div class = &quot;link e-oracle&quot;&gt;ORA-00937: not a single-group group function&lt;/div&gt; &lt;div class = &quot;link e-mysql&quot;&gt;Error 1140 Mi...&quot;</title>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=No_Group_By_Function&amp;diff=1889&amp;oldid=prev"/>
				<updated>2012-07-19T11:52:24Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;div class=&amp;#039;err&amp;#039;&amp;gt; &amp;lt;div class=params&amp;gt;schema:gisq&amp;lt;/div&amp;gt; &amp;lt;div class = &amp;quot;link e-oracle&amp;quot;&amp;gt;ORA-00937: not a single-group group function&amp;lt;/div&amp;gt; &amp;lt;div class = &amp;quot;link e-mysql&amp;quot;&amp;gt;Error 1140 Mi...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;div class='err'&amp;gt;&lt;br /&gt;
&amp;lt;div class=params&amp;gt;schema:gisq&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class = &amp;quot;link e-oracle&amp;quot;&amp;gt;ORA-00937: not a single-group group function&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class = &amp;quot;link e-mysql&amp;quot;&amp;gt;Error 1140 Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class = &amp;quot;link e-sqlite&amp;quot;&amp;gt;ORA-00937: not a single-group group function&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class = &amp;quot;link e-postgres&amp;quot;&amp;gt;Error 7 ERROR: Attribute xxx.xxx must be GROUPed or used in an aggregate function&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class = &amp;quot;link e-db2&amp;quot;&amp;gt;ORA-00937: not a single-group group function&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class = &amp;quot;link e-sqlserver&amp;quot;&amp;gt;ORA-00937: not a single-group group function&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Problem&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Usually we must have a GROUP BY clause if in aggregate function (such as SUM or COUNT) is used.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The exception is when only aggregate functions are used on the SELECT clause. If we mix aggregate and non-aggregate values then there must be a GROUP BY clause.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Solutions&amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
 &amp;lt;li&amp;gt;Remove the offending field from the SELECT line&amp;lt;/li&amp;gt;&lt;br /&gt;
 &amp;lt;li&amp;gt;Add the field to the GROUP BY clause&amp;lt;/li&amp;gt;&lt;br /&gt;
 &amp;lt;li&amp;gt;Aggregate the offending field&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=sql class='tidy'&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=sql class='setup'&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;SELECT name, MAX(population)&lt;br /&gt;
  FROM bbc&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;ecomm e-access&amp;quot; style=&amp;quot;display: none&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Connor</name></author>	</entry>

	</feed>