Processing When the divisor in SQL Server is "0"

Source: Internet
Author: User
Processing When the divisor in SQL Server is "0"

In SQL Server, when the divisor is 0, what should I do?
In such a situation, the version solved is that this operation cannot be executed, and the operation can be pre-determined before the division operation is executed. Here, we can use a case statement for judgment. If it is not suitable for calculation, we will do other things.

The Code is as follows:

1 case when construction area = 0 then null
2 when building area is null then null
3 when construction area <> 0 then approved payment amount/construction area end as unilateral cost


The building area here is the divisor. If it is 0 or null, you can perform your action as needed, that is, to change this null value to a field or something else, when the divisor building area is not 0, we can perform Division operations.

 

Related Article

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.