Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2011

    Unanswered: problem with update in sql table

    I have sql table with 3 columns id, parentid and name.I have attached the table i have .
    Also i have attched the table output i want.
    In the name column ,there are so may values out which yes and no are two values which occur more than once.

    I want to give parentid in the row corresponding to these yes and no values.
    the parentid for each of these row will be different.

    This parent id for any of these row will be the id of the row just above it.

    i tried it.but every yes is getting same parentid value and every no value is getting a common value.

    how can i correct it?it will be very kind of you to help me.
    Attached Files Attached Files

  2. #2
    Join Date
    Apr 2008
    Iasi, Romania
    Provided Answers: 3
    select id, parentid, name
    select id, parentid, name
    from afltest
    where name NOT IN ('yes', 'no')
    select id, id - 1 as parentid, name
    from afltest
    where name IN ('yes', 'no')
    ) a
    order by
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

Tags for this Thread

Posting Permissions

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