【发布时间】:2017-04-23 22:40:12
【问题描述】:
我有一张客户表,customerid 作为PK 和一个currentordertotal 字段。我想将currentordertotal 合并为两个客户记录。
例如:
Customer C1, Current Order Total = 2
Customer C2, Current Order Total = 4
我想将 C1’s Current Order Total 更新为它自己 (2) 加上 C2’s Current Order Total (所以 6)。
比如:
UPDATE customers SET currentordertotal = (itself + currentordertotal WHERE customerid = C2) WHERE customerid = C1;
我在网上搜索过类似的查询,但找不到。
这是一个 Oracle 数据库
【问题讨论】:
标签: sql oracle select sql-update