--order 502742 (analysis changed)

UPDATE nonuniqueitem nui
SET    nui.ChargedForLoss = nvl((SELECT 'Y'
                                FROM   wearerinventory winv
                                WHERE  winv.wearerinventory_id =
                                       nui.wearerinventory_id
                                       AND
                                       winv.losschargeinvoiceline_id <> 0
                                       AND
                                       winv.dateinactive < trunc(SYSDATE)),
                                'N');

commit;