【问题标题】:update column information based on select statment根据select语句更新列信息
【发布时间】:2016-09-16 21:16:18
【问题描述】:

我在 sql server 2008 中使用此查询从大量行中选择行数

(select *
from (select *,
             row_number() over (partition by 
                     [Patient Family registration no# رقم الملف] order by ((CONVERT(date,[date of visit] ) ))) as seqnum
      from MFC  
      ) t
where  seqnum = 1)

现在我需要将我选择的这些行的列调用(访问类型)更新为“新访问”,我该怎么做? 谢谢

【问题讨论】:

    标签: sql sql-server-2008 sql-server-2008-r2


    【解决方案1】:

    您可以使用可更新的 CTE:

    with toupdate as (
          select mfc.*,
                 row_number() over (partition by [Patient Family registration no# رقم الملف]
                                    order by CONVERT(date, [date of visit] )
                                   ) as seqnum
          from MFC  
         )
    update toupdate
        set TypeOfVisit = 'New Visit'
        where seqnum = 1;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-15
      • 1970-01-01
      • 2021-10-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多