Oracle DECODE function
Oracle decode function allow to transform data values at retrieval time.
Syntax :
DECODE(expr, search, result [, search, result ]... [, default ] )
Example :
We have a column named Floor, with values of GF, FF, SF and TF. When we run SQL queries, we want to transform these values into Ground Floor, First Floor, Second Floor and Third Floor.select
decode (
floor,
‘GF’,’Ground Floor’,
‘FF’,’First Floor’,
‘SF’,’Second Floor’,
‘TF’,’Third Floor’,
‘NOT KNOWN’
)
from
apartment;
No comments:
Post a Comment