DECODE()
DECODE() is a SQL function in the Oracle Specific category. Oracle: compares expression to each search value and returns the corresponding result. Like CASE but limited. The syntax is DECODE(expression, search1, result1, search2, result2, ..., default). It accepts expression, search1, result1, search2, result2, ..., default. It returns decoded result. A typical example: SELECT name, DECODE(department_id, 10, 'Finance', 20, 'IT', 30, 'HR', 40, 'Sales', 'Unknown' ) AS dept_name FROM employees; -- Oracle's predecessor to CASE expression A close relative is SEQUENCE (Oracle), which oracle: generates sequential numbers. Independent of tables. Accessed via NEXTVAL and CURRVAL. A close relative is ROWNUM / FETCH FIRST, which oracle: ROWNUM assigns sequential numbers to rows. Used for limiting results (pre-12c). A close relative is SYSDATE / CURRENT_DATE, which oracle: returns the current date and time of the database server. More about this category: Oracle-specific features — SEQUENCE, ROWNUM, SYSDATE, CONNECT BY, PL/SQL.