Difference between revisions of "COUNT"

From SQLZOO
Jump to: navigation, search
(Created page with "<table align='right' border='1'> <caption>Compatibility</caption> <tr><th colspan='3'>COUNT(f)</th></tr> <tr><td align='center'>'''Engine'''</td><td align='center'>'''OK'''</t...")
 
Line 9: Line 9:
 
<tr><td align='left'>sqlserver</td><td>Yes</td><td></td></tr>
 
<tr><td align='left'>sqlserver</td><td>Yes</td><td></td></tr>
 
</table>
 
</table>
<h3>COUNT</h3>
+
<h1>COUNT</h1>
 
<p>COUNT finds the number of non-null values in a column.</p>
 
<p>COUNT finds the number of non-null values in a column.</p>
 
<p>COUNT is an aggregate function it is normally used with GROUP BY.  </p>  
 
<p>COUNT is an aggregate function it is normally used with GROUP BY.  </p>  

Revision as of 10:57, 13 July 2012

Compatibility
COUNT(f)
EngineOKAlternative
ingresYes
mysqlYes
oracleYes
postgresYes
sqlserverYes

COUNT

COUNT finds the number of non-null values in a column.

COUNT is an aggregate function it is normally used with GROUP BY.

  SELECT region, COUNT(name)
    FROM bbc
   GROUP BY region 

With a GROUP BY region statement each region shows up just once. The COUNT column gives the number of countries for each region.

SELECT region, COUNT(name)
  FROM bbc
 GROUP BY region

See also

Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense