MERGE INTO a
USING b
ON (a.name = b.name)
WHEN MATCHED THEN
UPDATE
SET marks = a.marks - b.marks
WHERE a.marks <> b.marks
其中,对于样本数据:
CREATE TABLE A (Name, Marks) AS
SELECT 'Amit', 23 FROM DUAL UNION ALL
SELECT 'Rahul', 12 FROM DUAL UNION ALL
SELECT 'Gaur', 10 FROM DUAL;
CREATE TABLE b (Name, Marks) AS
SELECT 'Amit', 34 FROM DUAL UNION ALL
SELECT 'Rahul', 10 FROM DUAL UNION ALL
SELECT 'Gaur', 10 FROM DUAL;
3条答案
按热度按时间jexiocij1#
可以使用
MERGE
语句:其中,对于样本数据:
然后在
MERGE
之后,表A
包含:| 标记| MARKS |
| - -----| ------------ |
| -11| -11 |
| 2| 2 |
| 十个| 10 |
fiddle
qybjjes12#
只需在名称上连接表,然后减去值-
c7rzv4ha3#