Oracle common functions (but slightly lacking their own little finishing)

DECODE

​ DECODE(value ,if 1, then 1,if 2,then 2, ....,else)

Resolution:

if the condition = 1

​ return (value 1)

if conditions = 2

​ return (value 2)

​ else

​ return (default)

NVL

NVL (n1, n2)

Resolution:

​ if n1==null return n2 else return n1

​ if n1==null and n2==null return null

NVL2

Resolution:

NVL2 (n1, n2, n3)

​ if n1==null return NVL2()==n3 else return NVL2()==n2

NULLIF

​ NULLIF(n1,n2)

Resolution:

​ if n1==n2 return null else return n1

SUM

Calculate the sum of data

SUBSTR

1, SUBSTR (string string, int a, int b)
Parameter 1: String String to process
parameter 2: the start position of a character string taken (starting position is 0)
Parameter 3: b taken string length ( rather than an end position of the string)
, for example:
the SUBSTR ( "ABCDEFG", 0); // returns: ABCDEFG, interception of all characters
SUBSTR ( "ABCDEFG", 2) ; // returns: CDEFG, all characters after the start of the interception from C
SUBSTR ( "ABCDEFG", 0, 3); // returns: ABC, taken from a 3 characters
SUBSTR ( "ABCDEFG", 0, 100); // returns: ABCDEFG, 100 exceeds the string although most pretreated length, but will not affect the results returned, the system returns to pretreatment according to the maximum number of strings.
SUBSTR ( "ABCDEFG", -3, 3); // Returns: EFG, -3 demand parameter, a negative value indicates counting from the end opening, the arrangement position of the same string.

TO_CHAR

First, the date format conversion

  ** to_char (date, 'format'); **

```
`select to_date(``'2005-01-01 '``,``'yyyy-MM-dd'``) from dual;``select to_char(sysdate,``'yyyy-MM-dd HH24:mi:ss'``) from dual;`  
```

Second, digital format conversion

** to_char (number, 'format'); **

```
`select to_char(``88877``) from dual;``select to_char(``1234567890``,``'099999999999999'``) from dual;``select to_char(``12345678``,``'999,999,999,999'``) from dual;``select to_char(``123456``,``'99.999'``) from dual;``select to_char(``1234567890``,``'999,999,999,999.9999'``) from dual;`
```

Third, the money format conversion

**to_char(salary,'$99,99');**

```
`select TO_CHAR(``123``,``'$99,999.9'``) from dual;`
```

IV ** binary conversion: conversion of 10 hex 16 hex **

```
`select to_char(``4567``,``'xxxx'``) from dual;``select to_char(``123``,``'xxx'``) from dual;`
```

 

WM_CONCAT
implement row transfer function column, a column is about to check out the comma-separated values stitching, become a data. Equivalent group_concat

Guess you like

Origin www.cnblogs.com/-821L/p/12071265.html