Warning: NULL values are eliminated for aggregation or other set operations. "

Source: Internet
Author: User

.

Create Table TB
(
Id int,
Num int
)

Insert into TB select 1, 10
Insert into TB select 1, 20
Insert into TB select 2, 80
Insert into TB select 2, null

Select ID, sum (Num)
From TB
Group by ID

ID
----------------------
1 30
2 80

(The number of affected rows is 2)

Warning null values are eliminated for aggregation or other set operations.

Analysis: Aggregate functions cannot calculate null values, so they ignore
This prompt is only a warning, indicating that the null value is ignored.
The result is calculated as null is 0.

If you use
Select ID, sum (isnull (Num, 0 ))
From TB
Group by ID

Before the operation, isnull has converted the null value to 0,
So there is no problem with aggregate function operations.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.