Login     Register

        Contact Us     Search

XLeratorDB/statistics Documentation

SQL Server COUNT function


 
Updated: 6 August 2010

Use COUNT to count the number of rows in a resultant table that contain numbers.
Syntax
SELECT [wctStatistics].[wct].[COUNT] (
   <@TableName, nvarchar(4000),>
 ,<@ColumnName, nvarchar(4000),>
 ,<@GroupedColumnName, nvarchar(4000),>
 ,<@GroupedColumnValue, sql_variant,>)
Arguments
@TableName
the name, as text, of the table or view that contains the values to be used in the COUNT calculation.
@ColumnName
the name, as text, of the column in the table or view specified by @TableName that contains the to be used in the COUNT calculation.
@GroupedColumnName
the name, as text, of the column in the table or view specified by @TableName which will be used for grouping the results.
@GroupedColumnValue
the column value to do the grouping on.
 
Return Types
float
Remarks
·         COUNT returns that number of rows in the resultant table than can be evaluated as numbers. Nulls, text, and any value of a that cannot be implicitly converted to float are excluded.
·         No GROUP BY is required for this function even though it produces aggregated results.
Examples
 
CREATE TABLE #c1(
      [num] [varchar] (10) NULL
)
insert into #c1 values (1.5)
insert into #c1 values (2.5)
insert into #c1 values (2.75)
insert into #c1 values (3.2)
insert into #c1 values (5.675)
insert into #c1 values ('wct')
 
select wct.count('#c1','num','',NULL)
This produces the following result
-----------
5
 
(1 row(s) affected)







Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service