Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004

    Unanswered: Can I default a value for a subquery in the select line?

    I have a table that has pay changes for an employee. The table could have two rows per employee. So I am using a subquery to get both values on the same output row (the actual query is much more complicated, but this give you an idea):

    SELECT change_pct
    (Select change_pct
    FROM table1 b
    WHERE a.employee_id = b.employee_id)
    FROM table1 a
    WHERE employee_id='112233'

    My problem is that if there is no second row, I want to default the output to 0.

    Is that possible?

  2. #2
    Join Date
    Jun 2004
    Liverpool, NY USA
    select A.employee,a.change_pct,b.change_pct
    From Table1 A, Table1 B
    Where A.employee_id = B.employee_id(+)
    And A.change_pct <> B.change_pct(+);
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

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