Creating update query

  • Hi

     

    Simple I guess but didn't find it :

    I wanna have a update query like

     

    update ventven

    set ventven.codsuc = 'AT'

    from vligven

    where vligven.nofact = ventven.nofact

    and vligven.codart in ('TOT PPO01Z', 'TOT PPO000Z')

    and ventven.codnat = 'h'

    having count(ventven.nofact) = 2

     

    These are orders. Where there are two orderlines (= vligven), the status of the order'head' has to be changed into 'AT', otherwise not.

     

    Thx in advance

     

    Kind regards

     

    El Jefe


    JV

  • I think this is what you mean

    UPDATE h

    SET h.codsuc = 'AT'

    FROM ventven h

    INNER JOIN (SELECT l.nofact

    FROM vligven l

    WHERE l.codart IN ('TOT PPO01Z', 'TOT PPO000Z')

    GROUP BY l.nofact

    HAVING COUNT(*) = 2) a

    ON a.nofact = h.nofact

    WHERE h.codnat = 'h'

    Far away is close at hand in the images of elsewhere.
    Anon.

  • simple but great 😉

     

    thx


    JV

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

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