|
SQL Home
SQL TutorialIntroductionSQL Syntax SQL Select SQL Where SQL Order By SQL Top SQL Distinct SQL In SQL Alias SQL Join SQL Inner Join SQL Outer Join SQL Insert SQL Update SQL Delete SQL Functions SQL Count SQL Create SQL Create Database SQL Create Table SQL Create Index SQL Alter Table SQL Summary Got a MySpace Page?Get "www.yourname.com" for your MySpace page. Learn how >>. |
SQL CountA commonly used aggregate function in SQL is COUNT. COUNT returns the number of rows that match the given criteria. COUNT(*)If we only want to see how many records are in a table (but not actually view those records), we could use COUNT(*). COUNT(*) returns everything - including null values and duplicates. SQL statement
Source Table
Result
COUNT(column name)If we want to see how many non-null values are in a given column, we use COUNT(column name) where column name is the name of the column we want to test. SQL statement
Source Table
Result
Combining COUNT & DISTINCTIf we only want to see how many unique names are in the table, we could nest the DISTINCT inside a COUNT function. SQL statement
Result
Enjoy this website?
Oh, and thank you for supporting Quackit! |
FREE Hosting!With every domain name you register with ZappyHost, you get FREE (ad supported) hosting.PLUS you get:
Featured Template:
(Build your websites in minutes!) |