oracle中decode函数的用法
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
哈哈,这样就简单明了啦

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



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

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

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,

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

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.

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,

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...

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
