Using MS SQL COUNT

One of the most used functions when writing queries in MS Sql is COUNT(). COUNT() , an "aggregate function", returns the number of records in the query.

Let's have a table named PRODUCTS as follows..

Product Price
Chocolate 5
Water 5
Pasta 3
Pen 10
Chocolate 7
Tea 20

The following query is written to fetch the number of records in this table.

SELECT COUNT(*) FROM PRODUCTS

The result will return us as 6.



You May Interest

How to Rebuild the Master Database in SQL Server ?

Differences Between Stored Procedure and Function in MS SQL

What are the INTERSECT Operators in SQL Server ?

What is the Difference Between CHAR and VARCHAR Datatypes in SQL ...

Disadvantages of Using Stored Procedures in MS SQL