sql - Update minutes value to 0 for unmatched data with having keeping one data as it is -
need update data based on specific column unmatched & keeping 1 data is
also need take care of performance huge data
you can use row_number()
. example:
with toupdate ( select t.*, row_number() on (partition therapyadmissionid, units, totalminutes order documentstartdate) seqnum t ) update toupdate set units = 0, totalminutes = 0 seqnum > 1;
i should note need suggests have flaw in data model. units
, totalminutes
should stored in table.
Comments
Post a Comment