Pages

Friday 11 January 2013

COUNT Function in Sql Server

The count function returns the number of rows which are currently in existence.It is used when number of rows in the collection are unknown.

The Count function is very useful to count the occurrence of column values that have a value.

Warning: Null value is eliminated by an aggregate or other SET operation.

SELECT COUNT(*) FROM tablename

If you use the DISTINCT keyword within your query with COUNT function parentheses, you’ll only get the count of distinct values for that column. For example:

SELECT COUNT(DISTINCT Shelf) ShelfCount
FROM tbl_ProductInventory

No comments:

Post a Comment