Oracle decode function syntax introduction.

Source: Internet
Author: User

As one of the Oracle functions, the Oracle decode function plays a very important role in the Oracle database. The following describes the usage of the Oracle decode function for your reference.

We all know that the Oracle function library provides N more useful functions, such as nvl, sign, and round, which we often use, oracle decode functions are powerful. The Oracle decode function is used as follows:

Decode (expression, condition 1, result 1, condition 2, result 2,...) contains several conditions and results depending on the individual, as shown in

Decode (sign (100-20), 1,100,-100) means that when 100-20) is greater than zero, the result is 20, and when-20) is less than zero, the result is 100. The sign is only a function for determining the symbol.

If we want to adjust the salaries of employees in an enterprise and increase the salaries by 3000 for employees of less than 10% yuan and 3000 for employees of more than 5% yuan, then our general practice is to judge the wages, if the value is greater than 3000, 5% is added, and if the value is lower than 3000, 10% is added. However, with this Oracle decode function, you can simply use the following statement:

 
  1. 1. select decode (sign (salary-3000), 1, salary * 1.1,-1, salary * 1.05) from employee

The preceding content describes the usage of the Oracle decode function.

Use of Oracle to_char Functions

Implementation of oracle function return table

How to uninstall an Oracle database in Windows

How to install Oracle as a Linux Service

Learn about the Oracle FBI Index

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.