Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - SQL Usage » Queries and data modification » Summarizing, grouping, and sorting query results » Aggregate functions that summarize query results

 

Aggregate functions and NULL

Any NULLS in the column on which the aggregate function is operating are ignored for the function except COUNT(*), which includes them. If all the values in a column are NULL, COUNT(column_name) returns 0.

If no rows meet the conditions specified in the WHERE clause, COUNT returns a value of 0. The other functions all return NULL. Here are examples:

SELECT COUNT( DISTINCT Name )
   FROM Products
   WHERE UnitPrice > 50;
COUNT(DISTINCT Name)
0
SELECT AVG( UnitPrice )
   FROM Products
   WHERE UnitPrice > 50;
AVG(Products.UnitPrice)
( NULL )