Beruflich Dokumente
Kultur Dokumente
Single-Row Functions
Input Output
Function
arg 1 Function
performs action
arg 2
Result
value
arg n
Functions
Single-row Multiple-row
functions functions
Character
General Number
Single-row
functions
Conversion Date
Character
functions
Case-manipulation Character-manipulation
functions functions
LOWER CONCAT
UPPER SUBSTR
INITCAP LENGTH
INSTR
LPAD | RPAD
TRIM
REPLACE
Function Result
LOWER('SQL Course') sql course
UPPER('SQL Course') SQL COURSE
INITCAP('SQL Course') Sql Course
Function Result
CONCAT('Hello', 'World') HelloWorld
SUBSTR('HelloWorld',1,5) Hello
LENGTH('HelloWorld') 10
INSTR('HelloWorld', 'W') 6
LPAD(salary,10,'*') *****24000
RPAD(salary, 10, '*') 24000*****
TRIM('H' FROM 'HelloWorld') elloWorld
1 2 3
1 2
1 2 3
DUAL is a dummy table you can use to view results
from functions and calculations.
1 2
1 2 3
Function Description
• MONTHS_BETWEEN ('01-SEP-95','11-JAN-94')
19.6774194
• NEXT_DAY ('01-SEP-95','FRIDAY')
'08-SEP-95'
• LAST_DAY('01-FEB-95') '28-FEB-95'
Data type
conversion
From To
NUMBER VARCHAR2
DATE VARCHAR2
From To
TO_NUMBER TO_DATE
TO_CHAR TO_CHAR
TO_CHAR(date, 'format_model')
ddspth fourteenth
SELECT last_name,
TO_CHAR(hire_date, 'fmDD Month YYYY')
AS HIREDATE
FROM employees;
TO_CHAR(number, 'format_model')
These are some of the format elements you can use
with the TO_CHAR function to display a number value
as a character:
9 Represents a number
0 Forces a zero to be displayed
$ Places a floating dollar sign
L Uses the floating local currency symbol
. Prints a decimal point
, Prints a thousand indicator
TO_DATE(char[, 'format_model'])
0–49 50–99
If two digits The return date is in The return date is in
of the 0–49 the current century the century before
current the current one
year are: The return date is The return date is in
50–99 in the century after the current century
the current one
F3(F2(F1(col,arg1),arg2),arg3)
Step 1 = Result 1
Step 2 = Result 2
Step 3 = Result 3
SELECT last_name,
NVL(TO_CHAR(manager_id), 'No Manager')
FROM employees
WHERE manager_id IS NULL;
1 2
1 2
1 2 3
SELECT last_name,
COALESCE(commission_pct, salary, 10) comm
FROM employees
ORDER BY commission_pct;