You're here: Snippet Directory » Databases (26)
Language:

Count of Distinct fields in a table

Language: English
Programming Language: SQL
Published by: wapu [not registered]
Last Update: 5/15/2006
Views: 1221


Description

This is goodfor getting a count of the instances of a value in a table. eg. How many Addresses in the table are from each state?

Code

1 /*This will get a count of all the instances of a state in the table*/ 2 select stateField, count(*) as Total 3 from AddressTable 4 group by stateField

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS