Difference between revisions of "No Group By Function"

From SQLZOO
Jump to: navigation, search
(Created page with "<div class='err'> <div class=params>schema:gisq</div> <div class = "link e-oracle">ORA-00937: not a single-group group function</div> <div class = "link e-mysql">Error 1140 Mi...")
 
 
Line 29: Line 29:
 
<div class="ecomm e-access" style="display: none"></div>
 
<div class="ecomm e-access" style="display: none"></div>
 
</div>
 
</div>
 +
[[Category:Error]]

Latest revision as of 14:20, 9 August 2012

schema:gisq

Problem

Usually we must have a GROUP BY clause if in aggregate function (such as SUM or COUNT) is used.

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.

Solutions

  • Remove the offending field from the SELECT line
  • Add the field to the GROUP BY clause
  • Aggregate the offending field
 
 
SELECT name, MAX(population)
  FROM bbc
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense