Help with an update

  • I need to run an update on the data below. I need to update the profile_id's with '0' to the same profile ID used with the con_id and site_session_id and event_type != 27

    So

    140227346   19809366     705269424          10

    140227346   0                705269424          10

    140227346   0                705269424          10

    140227346   0                705269424          20

    becomes this

    140227346   19809366     705269424          10

    140227346   19809366     705269424          10

    140227346   19809366     705269424          10

    140227346   19809366     705269424          20

    con_id(int)   profile_id(int)  site_session_id(int)  event_type(int)

    140227346   19809366     705269424          10

    140227346   0                705269424          10

    140227346   0                705269424          10

    140227346   0                705269424          20

    140227282   19809363     460894067          10

    140227282   19809363     460894067          20

    140227016   19809367     1229280036         27

    140227016   0                1229280036         10

    140227016   0                1229280036         10

    140227016   0                1229280036         10

    140227016   0                1229280036         10

    140228214   19809395    141334294          27

    140228214   0               141334294          10

    140228214   0               141334294          10

    140228214   0               141334294          10

    140228214   0               141334294          10

    140227784   19809414    989395465          27

    140227784   0               989395465          10

    140227784   0               989395465          10

    140228477   19809416    481191756          27

    140228477   0               481191756          10

    140228477   0               481191756          10

  • Update T

     Set profile_id = T2.profile_id

    from

      Table T

      join

     (select distinct con_id

       , profile_id

       ,  site_session_id

       From

      Table

      where Profile_id <> 0) T2

     on T.con_id =T2.con_id  and T.site_session_id =T2.site_session_id

    where T.event_type <> 27 and T.Profile_id = 0

     

    HTH

     


    * Noel

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

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