更新最新日期 [英] update with the latest date

查看:42
本文介绍了更新最新日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张如下所示的表格:

I have a table as shown below:

我需要将它们更新为最新的last_order_date,表可以如下所示:

I need to update them into the latest last_order_date, which the table can be shown as below:

我有 20000 多条记录,我需要一个查询来一次更新它们.

I have 20000 plus records, I need a query to update them at once.

感谢您花时间看它.

推荐答案

在最大计算子查询上使用连接

Using join on max calculating subquery

UPDATE t
SET t.last_order_date =a.maxDate
FROM tableName t
INNER JOIN
 ( SELECT cust_id ,MAX(last_order_date) As maxDate
   FROM tableName GROUP BY cust_id ) a
ON a.cust_id =t.cust_id 

这篇关于更新最新日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆