---
title: "SQL COUNT(*) Vs COUNT(DISTINCT)"
description: "COUNT function in SQL. Explained how to use to avoid NULL values and Duplicate values."
url: https://srinimf.com/2016/03/24/2-key-differences-of-count-and-countdistinct-db2-v11/
date: 2016-03-24
modified: 2026-10-10
author: "Srini"
categories: ["DB2"]
tags: ["DB2 v11 COUNT aggregate function"]
type: post
lang: en
---

# SQL COUNT(*) Vs COUNT(DISTINCT)

The `COUNT()` function in SQL is a helpful tool for writing queries. It allows you to determine the number of rows in a result set that meet certain criteria. By using this function, you can easily calculate and display the desired information based on your specific requirements.

Related[DB2 SQL Functions Count Vs Count_Big](https://srinimf.com/2012/04/25/db2-built-in-function-count-and-count_big/)

## COUNT(*)

Counting rows in SQL is you can do with a function in SQL. The COUNT(*) function in SQL gives a count of Null values, Non-null values, and Duplicate values.

Related[SQL Count Vs Count Distinct With Group By](https://srinimf.com/2022/11/22/sql-count-vs-count-distinct-with-group-by/)

## COUNT(Expression)

The COUNT(Expression) or COUNT(ALL Expression) function gives a count of rows except Null values.

## COUNT(DISTINCT function)

The COUNT(DISTINCT function) gives a count of all rows except duplicates and Null values.

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2016%2F03%2F24%2F2-key-differences-of-count-and-countdistinct-db2-v11%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2026%2F02%2Fcropped-logo.png%3Ffit%3D96%252C96%26ssl%3D1&description=SQL%20COUNT%28%2A%29%20Vs%20COUNT%28DISTINCT%29)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2016/03/24/2-key-differences-of-count-and-countdistinct-db2-v11/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2016/03/24/2-key-differences-of-count-and-countdistinct-db2-v11/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2016/03/24/2-key-differences-of-count-and-countdistinct-db2-v11/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2016/03/24/2-key-differences-of-count-and-countdistinct-db2-v11/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20SQL%20COUNT%28%2A%29%20Vs%20COUNT%28DISTINCT%29&body=https%3A%2F%2Fsrinimf.com%2F2016%2F03%2F24%2F2-key-differences-of-count-and-countdistinct-db2-v11%2F&share=email)
-

### Like this:

Like Loading…
