Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • DECODE function

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 694
    Comment on it

    DECODE function:

    DECODE function works similar to if-else statement or case statement. DECODE compares expression to each search value one by one and returns the result of that search which is equal to the expression. If there is no match than default value will get return.

    DECODE Syntax:

    DECODE(col|expression, search1, result1
    [, search2, result2,...,]
    [, default])

    Example:

    SELECT EMPId,
           DECODE (EMPId, 1, 'Delhi', 
                                 2, 'Texas', 
                                 3, 'London', 
                                 4, 'Mumbai',
                                    'DefaultVal') 
           "Location" FROM Employee
           WHERE Salary < 17000;

    The above query will decode the value of EMPId and it will return Delhi if EMPId is 1 , if EMPId is 2 then it will return texas , if EMPId is 3 then it will return London, if EMPId is 4 it will return Mumbai otherwise it will return default value.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: