- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the result of count function in the NULL value present in DB2 table?
The COUNT function in DB2 is used to return the number of rows which satisfies the given criteria. The GROUP BY is used to divide the rows in the groups based on the criteria given in the query.
If we perform the GROUP BY on INVOICE_ID and there are few rows having NULL value in INVOICE_ID then the null values form a separate group. For example, if we have below table.
ORDER_ID | INVOICE_ID |
---|---|
A11234 | 3214 |
A55611 | 3214 |
A99867 | NULL |
A55671 | 3214 |
A88907 | NULL |
A56012 | 6701 |
On executing the query which performs GROUP BY on INVOICE_ID and counts the number of rows, we will get the result below.
SELECT INVOICE_ID, COUNT(*) AS INVOICE COUNT FROM ORDERS GROUP BY INVOICE_ID;
INVOICE_ID | INVOICE COUNT |
---|---|
3214 | 3 |
NULL | 2 |
6701 | 1 |
- Related Articles
- What is the purpose of “NOT NULL WITH DEFAULT” clause used in DB2 table column?
- What is NULL check and insertion rule in a DB2 table?
- How to store a NULL value in a particular column of a DB2 table using COBOL-DB2 program?
- Display the result with not null value first and then with null value in MySQL
- What is the use of the VALUE function in a DB2? Explain with the help of an example
- What will happen if a NULL value is detected for a SQL statement in COBOL-DB2 program and the NULL indicator is not used?
- Find the count of EMPTY or NULL columns in a MySQL table?
- What is the definition and usage of alternate key in a DB2 table?
- What will be the result if SQLCA is not included in a COBOL-DB2 program?
- What is the significance of ACCESSTYPE and INDEXONLY column of a PLAN table in DB2?
- Write a SQL query to count the number of duplicate TRANSACTION_ID in an ORDERS DB2 table
- What MySQL MAKE_SET() function returns if the value of the bit is 1 and the first string is NULL?
- How to verify NULL value in DB2 column data using COBOL paragraph?
- What is the execution result when non-SQL changes are made in a DB2 program without BIND?
- Count number of occurrences of records in a MySQL table and display the result in a new column?

Advertisements