Wednesday, April 23, 2008

Count() Function

Ive seen it used but never used it myself. I did have the need to use it today!
SELECT COUNT(*) AS num_cust
FROM Customers
Results num_cust ----------- 5

In the example above, Count(*) is used to count all roes, regardless of values. The count is returned in num_cus

My select statement:
SELECT count(cus_cd)
FROM dbo.customer
WHERE (cus_status = 'A')

I returned the number of active customers

No comments: