sql - Update minutes value to 0 for unmatched data with having keeping one data as it is -


enter image description here

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

Popular posts from this blog

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Permission denied. Laravel linux server -