Tips for using the decode () function in Oracle

Source: Internet
Author: User

I. Software Environment

1. windows nt4.0 + oracle 8.0.4

2. oracle installation path: c: \ orant

Ii. Meaning

 

Iii. Usage

1. Compare the size

Select decode (sign (variable 1-variable 2),-1, variable 1, variable 2) from dual; -- smaller value

The sign () function returns 0, 1, and-1 respectively based on a value of 0, positive, or negative.

For example:

Variable 1 = 10, variable 2 = 20

Then sign (variable 1-variable 2) returns-1, and the decode decoding result is "variable 1", achieving the goal of getting a smaller value.

2. Table and View Structure Conversion

There is a sales table sale with the following structure:

 

Data to be converted to the following structure:

 

The SQL statement for structure conversion is:

 

Related Articles]

  • Easily modify the size of an Oracle database table
  • Hints adjustment mechanism used by Oracle
  • Oracle remote replication and Remote Disaster Recovery classic Analysis

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.