Oracle translate and decode

What is translate and decode in oracle?

Translate: translate function replaces a sequence of characters in a string with another set of characters. The replacement is done single character at a time.

Syntax:
translate( string1, string_to_replace, replacement_string )

Example:
translate ('1tech23', '123', '456);

Decode: The DECODE function compares one expression to one or more other expressions and, when the base expression is equal to a search expression, it returns the corresponding result expression; or, when no match is found, returns the default expression when it is specified, or NA when it is not.

Syntax:
DECODE (expr , search, result [, search , result]... [, default])

Example:
SELECT employee_name, decode(employee_id, 10000, ‘tom’, 10001, ‘peter’, 10002, ‘jack’ 'Gateway') result FROM employee;

Use of Translate Function in Oracle.
Use of Translate Function in Oracle - The translate function performs a character wise replacement of a string...
What are Group Functions in Oracle?
What are Group Functions in Oracle? - This function returns the number of rows in the group. A column name or ‘*’ may be passed as a parameter...
WHERE clause vs HAVING clause
WHERE clause vs HAVING clause - HAVING clause is used with group function and it is written after GROUP BY clause. The WHERE clause is used when you want to specify a condition for columns...
Post your comment