DB2 – Built-in Function Count and Count_Big

The function COUNT we use to get number of rows in a table.

Select Emp_name, Count(*)  from EMP;

This will give Employee names and against each row it gives number of rows.

Select Count(Dept_Name) from EMP where Sex=’M’;  This give number of department names having Male employee.


It is similar to the COUNT, except that the result is greater than maximum value of Integer.

Select Count_Big(DISTINCT Emp_name) from emp;

COUNT_BIG(*) – This is also similar to the COUNT(*), except the result is greater than of Integer.

  • One more point is we can change the result data type with COUNT_BIG function
  • UDF – It can be used in user defined functions

Author: Srini

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