Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

SQL COUNT(*) Vs COUNT(column_name)

By , 11 May 2010
Rate this:
Please Sign up or sign in to vote.
Well, another major point is that the two variants serve different purposes by definition.
-- Count rows where 'column_name' is NOT NULL
SELECT COUNT(column_name) FROM Table_Name
-- Count ALL rows in Table_Name 
-- ... which you just as well can exchange with a constant
In other words, it's not "which one is faster", it's "which one serves the purpose".


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Dennis Ålund
Database Developer Oddbit
Indonesia Indonesia
Oddbit is an IT consultancy company that specialize in databases and software development with a focus on security. The company is located in Stockholm, Sweden and Jakarta, Indonesia.

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 12 May 2010
Article Copyright 2010 by Dennis Ålund
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid