Home Database Mysql Tutorial oracle中decode函数的用法

oracle中decode函数的用法

Jun 07, 2016 pm 05:45 PM
100 decode sign

oracle函数库中提供了很多有用的函数,比如nvl,sign,round等,其中用得比较多的,功能比较大的还是decode这个函数。这个函数的用法如下:

  decode(表达式,条件1,结果1,条件2,结果2,...)中间有几个条件与结果根据个人而定,如

  decode(sign(100-20),1,20,-1,100)意思是说当(100-20)大于零时,结果为20,而当(100-20)小于零时,结果为100,其中的sign只是一个判断符号的函数

  假如要对一个企业的员工进行工资调整,对于3000块以下的提高10%,3000块以上的提高5%,那么如果用我们一般的做法就是对工资进行判断,如果大于3000,就加5%,而低于3000的就加10%。不过现在有了这个decode函数,那么就可以简单的用下面的语句:

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

  哈哈,这样就简单明了啦

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use the SIGN function in Excel to determine the sign of a value How to use the SIGN function in Excel to determine the sign of a value May 07, 2023 pm 10:37 PM

The SIGN function is a very useful function built into Microsoft Excel. Using this function you can find out the sign of a number. That is, whether the number is positive. The SIGN function returns 1 if the number is positive, -1 if the number is negative, and zero if the number is zero. Although this sounds too obvious, if you have a large column containing many numbers and we want to find the sign of all the numbers, it is very useful to use the SIGN function and get the job done in a few seconds. In this article, we explain 3 different methods on how to easily use the SIGN function in any Excel document to calculate the sign of a number. Read on to learn how to master this cool trick. start up

Advanced usage and skill sharing of Oracle DECODE function Advanced usage and skill sharing of Oracle DECODE function Mar 08, 2024 am 10:30 AM

The DECODE function in Oracle database is a very commonly used function, which can select among a set of values ​​based on the result value of an expression. The syntax of the DECODE function is as follows: DECODE(expression, search_value1, result1, search_value2, result2,..., default_result) where expression is the expression to be compared, s

Oracle DECODE function detailed explanation and usage examples Oracle DECODE function detailed explanation and usage examples Mar 08, 2024 pm 03:51 PM

The DECODE function in Oracle is a conditional expression that is often used to return different results based on different conditions in query statements. This article will introduce the syntax, usage and sample code of the DECODE function in detail. 1. DECODE function syntax DECODE(expr,search1,result1[,search2,result2,...,default]) expr: the expression or field to be compared. search1,

Basic usage analysis of DECODE function in Oracle Basic usage analysis of DECODE function in Oracle Mar 07, 2024 pm 04:09 PM

Analysis of the basic usage of the DECODE function in Oracle In the Oracle database, the DECODE function is a very commonly used function, used to implement logical judgment and numerical replacement similar to multi-layer if-else statements. The basic syntax of the DECODE function is as follows: DECODE(expr,search1,result1,search2,result2,...,default_result) where the parameter meanings are as follows: expr

The idea of ​​​​sqlmap processing sign encryption The idea of ​​​​sqlmap processing sign encryption May 14, 2023 am 11:52 AM

When I tested the company's APP, I found that we added a 32-bit character to all parameter contents and finally performed MD5 encryption. Since the APP processing process first verifies whether the sign is correct, if the signature verification fails, it will not be able to enter the database at all. In order to use SQLMAP to test it, I wrote a script for proxy data. After intercepting the data packet , perform encrypted replacement of its parameter content and 32 characters. Note: This script is suitable for the company's internal system, because you can know the encryption process; or you can get the encryption method of the front-end JS. First, I wrote a program using Django to simulate the company's system. The process was to obtain the POST ID and token, and add a custom encrypted word.

Advanced skills and case studies on DECODE function in Oracle Advanced skills and case studies on DECODE function in Oracle Mar 07, 2024 pm 05:48 PM

The DECODE function in Oracle is a very powerful and commonly used function, used to implement logical judgment and value replacement in data query and processing. This article will explore advanced techniques and application cases of the DECODE function, and give specific code examples. 1. Introduction to DECODE function The DECODE function is a conditional expression function in Oracle database, which is used to implement logical judgment and value replacement similar to if-then-else. The syntax is as follows: DECODE(expr,

Oracle DECODE function example analysis and application scenarios Oracle DECODE function example analysis and application scenarios Mar 08, 2024 am 11:24 AM

The OracleDECODE function is a very commonly used conditional expression function. Its main function is to convert the result of the expression according to the specified conditions and return the corresponding value. The syntax of the DECODE function is as follows: DECODE(expr,search1,result1,search2,result2,...,default_result) where expr is the expression that needs to be judged, search1, search2...

Detailed explanation and application scenarios of Oracle DECODE function examples Detailed explanation and application scenarios of Oracle DECODE function examples Mar 07, 2024 pm 12:51 PM

Oracle database is a popular relational database management system that provides a wealth of functions and tools to handle complex data operations. Among them, the DECODE function is one of the most commonly used functions, which can convert and process data according to specified conditions. This article will introduce Oracle's DECODE function in detail, including its syntax structure, functional features, and practical application scenarios, and provide specific code examples. 1. The syntax structure of the DECODE function The syntax structure of the DECODE function is as follows: D

See all articles