Today, I met Oracle's TRIM, TRUNC, and DECODE functions. I will record my experiences for future reference.
Today, I met Oracle's TRIM, TRUNC, and DECODE functions. I will record my experiences for future reference.
Today, I met Oracle's TRIM, TRUNC, and DECODE functions. I will record my experiences for future reference.
1. TRIM function: used to remove spaces at the beginning and end of a string line.
Select trim ('yichangzyh') "TRIM e.g ."
FROM dual;
TRIM e.g.
YICHANGzyh
2. TRUNC function: truncation function.
SELECT trunc (sysdate) "truncated to the current day ",
Trunc (sysdate, 'Year') "trunc (sysdate, 'Year ",
Trunc (sysdate, 'month') "trunc (sysdate, 'month ",
Trunc (sysdate, 'day') "intercepts to the first day of the week ",
Trunc (sysdate, 'hh24') "truncated to hour (0 minutes 0 seconds )",
Trunc (sysdate, 'mi') "truncated to minute (0 s )"
FROM dual;
Truncate to the day, intercept to the first day of the year, intercept to the first day of the month, intercept to the first day of the week, intercept to the hour (0 minutes 0 seconds), intercept to the minute (0 seconds)
, 17:00:00
3. DECODE function: Condition judgment.
Decode (condition, value 1, return value 1, value 2, return value 2,... value n, return value n, default value)
The function has the following meanings:
IF condition = value 1 THEN
RETURN (translation value 1)
ELSIF condition = value 2 THEN
RETURN (translation value 2)
......
ELSIF condition = value n THEN
RETURN (translation value n)
ELSE
RETURN (default)
END IF