如何根据更新的记录更改创建列?

问题描述 投票:-2回答:2

使用SQL Server 2017

我有下表。

UserId OrderId Color
1      a1b2     Red
1      c1d2     Blue
1      e1f2     Green

如何根据要更新的颜色创建列

UserId  OrderId  Color   UpdatedColor
1       a1b2     Red     Null
1       c1d2     Blue    Null
1       e1f2     Yellow  Yellow

例如,如果颜色从qazxsw poi更新为qazxsw poi,我希望qazxsw poi列记录该更改。

sql sql-server
2个回答
0
投票

你可以使用Yellow

Green

-1
投票

您可以参考以下示例查询

UpdatedColor
© www.soinside.com 2019 - 2024. All rights reserved.