Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 将不匹配数据的分钟值更新为0,并保持一个数据不变_Sql_Sql Server_Sql Server 2008_Sql Server 2005 - Fatal编程技术网

Sql 将不匹配数据的分钟值更新为0,并保持一个数据不变

Sql 将不匹配数据的分钟值更新为0,并保持一个数据不变,sql,sql-server,sql-server-2008,sql-server-2005,Sql,Sql Server,Sql Server 2008,Sql Server 2005,需要根据不匹配的特定列更新某些数据&保持一个数据不变 还需要注意性能,因为这是针对海量数据的您可以使用行号()。例如: with toupdate as ( select t.*, row_number() over (partition by therapyadmissionid, units, totalminutes order by documentstartdate) as seqnum from t ) update toup

需要根据不匹配的特定列更新某些数据&保持一个数据不变


还需要注意性能,因为这是针对海量数据的

您可以使用
行号()。例如:

with toupdate as (
      select t.*,
            row_number() over (partition by therapyadmissionid, units, totalminutes order by documentstartdate) as seqnum
      from t
     )
update toupdate
    set units = 0,
        totalminutes = 0
    where seqnum > 1;
我应该注意到,这样做的需要表明您的数据模型中存在缺陷。
单位
总分钟
可能应存储在另一个表中