Decode function to determine a condition greater than or equal to

Source: Internet
Author: User

The decode function can replace the results of a query, and decode actually function like an if statement.

Decode (VAR,VAR1,VALUE1,VAR2,VALUE2,VAR3,VALUE3) is equivalent to if Var=var1 then ... else if Var=var2 then ... else var=var3 then ...

But only if it is equal to the situation, if the judgment is greater than less than the case, such as if a>b, the only use of decode is not possible, you need to add the sign () function.

The function of the sign function is very simple, sign (VAR), if var>0, returns 1, if var<0, returns 1, if var=0, returns 0, you can make the following rewrite for a>b this situation:

Decode (A-B), -1, ' A<b ', 0, ' a=b ', 1, ' a>b ');


Decode function to determine a condition greater than or equal to

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.