Decode in Oracle

Source: Internet
Author: User
Original: Decode in Oracle

The Decode function is equivalent to a conditional statement (IF). It compares the input value to the parameter list in the function and returns a corresponding value based on the input value. The parameter list of a function is a number of sequential pairs consisting of several numeric values and their corresponding result values. Of course, the function also has a default return value if it fails to match any one of the actual argument order pairs successfully. Unlike other functions in SQL, the Decode function can also recognize and manipulate null values.
Its specific syntax format is as follows:
DECODE (Input_value,value,result[,value,result ...] [, Default_result]);
which
Input_value the value to be processed. The decode function compares this value to a series of order pairs to determine the final return result
Value is the numeric value of a constituent order pair. If the input value matches successfully, the corresponding result is returned. corresponding to an empty return value, you can use the keyword NULL for the corresponding
result is the resulting value of a constituent sequence couple
The default value returned by the function when the Default_result failed to match any of the sequence pairs successfully
The following example shows how to read an item under the Blood_test_flag column in the User Checkup table Seapark as an argument support value for the Decode function.
SELECT Checkup_type,
DECODE (Blood_test_flag, ' Y ', ' Yes ', ' N ', ' No ', NULL, ' None ', ' Invalid ')
From Checkup;

Decode in Oracle

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.