SQL Tutorial


SQL SELECT
SQL DISTINCT
SQL WHERE
SQL AND OR
SQL IN
SQL BETWEEN
SQL LIKE
SQL ORDER BY
SQL Functions
SQL COUNT
SQL GROUP BY
SQL HAVING
SQL ALIAS
SQL JOIN
SQL OUTER JOIN
SQL Subquery
SQL UNION
SQL UNION ALL
SQL INTERSECT
SQL MINUS














Data Warehousing & Business Intelligence
Area Codes Info
State Info
HTML Tutorial
















Home
SQL Commands
Table Manipulation
SQL Syntax

SQL COUNT

Another arithematic function is COUNT. This allows us to COUNT up the number of row in a certain table. The syntax is,

SELECT COUNT("column_name")
FROM "table_name"

For example, if we want to find the number of store entries in our table,

Table Store_Information
store_name Sales Date
Los Angeles $1500 Jan-05-1999
San Diego $250 Jan-07-1999
Los Angeles $300 Jan-08-1999
Boston $700 Jan-08-1999

we'd key in

SELECT COUNT(store_name)
FROM Store_Information

Result:

Count(store_name)
4

COUNT and DISTINCT can be used together in a statement to fetch the number of distinct entries in a table. For example, if we want to find out the number of distinct stores, we'd type,

SELECT COUNT(DISTINCT store_name)
FROM Store_Information

Result:

Count(DISTINCT store_name)
3


Next Section

Site Map   |   Resources

1