Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    69

    Unanswered: SELECT inside DECODE

    I am trying to execute the following code in oracle :

    select decode(1,1, (select col1 from emp where col1=2)) from emp

    but getting error message as

    ERROR at line 1:
    ORA-01427: single-row subquery returns more than one row

    Is there a possibility that I could tell the compiler to take the first returned row in the query (just in case there will be multiple rows in the output)

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Yes:

    select decode(1,1, (select col1 from emp where col1=2 and rownum=1)) from emp

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •