Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL Server
Expertise: Beginner
Oct 11, 1999

Counting Specific Records

Question:
How do I count the records for a specific field? For example, I'm building a table for homes in a county. In the table are fields for cities and addresses for homes. I want to be able to get the results of how many homes are located in city1, how many homes are in city2, etc.

I've read things on Count and Move. Am I headed in the right direction?

Answer:
I'm not certain this will help you, but I think you are after COUNT DISTINCT CITY, which will give you the distinct number of entries in the city column.

Say you're in California and your table has 1,000 records in it. You have 650 Los Angeles records, 250 San Francisco records, and 100 Santa Barbara records. COUNT DISTINCT CITY would then be three.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap