2 Key Differences of COUNT(*) and COUNT(DISTINCT) in DB2 v11

The usage of COUNT() function is useful in writing SQL queries. I have explained how you can use this function as per your requirement.

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.

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.

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.