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

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -