Update "Case When" or anything like that

  • Hi @all

    I have no idea how to get a solution for my problem.

    A table like that:

    kPriority, kPageId, kPageName

    1,5000,AName.pdf

    1,5001,Bname.pdf

    1,5002,Cname.pdf

    2,5003,Gname.pdf

    2,5001,Bname.pdf

    3,5003,Gname.pdf

    Now i need a query that updates the kPageName-Fields to this:

    1,5000,AName.pdf

    1,5001,Bname.pdf

    1,5002,Cname.pdf

    2,5003,Gname.pdf

    2,5001,---

    3,5003,---

    If there is more than one row with the same kPageId, update the kPageName-Fields to "---", except the kPageName-Field with the lowest kPriorityId for this kPageId

    I hope you can follow me, and give me a little help....

    Thanks.

  • How about this:

    update TBL set kPageName = '---'

    from yourTable TBL

    join (select (min(kPriority) as pri, kPageId from yourTable group by kPageID) LP

    ON TBL.kPageID = LP.kPageID and TBL.kPriority > LP.pri

    The probability of survival is inversely proportional to the angle of arrival.

  • you are a genius!

    thanks.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply