update (select titles.ytd_sales,sales.qty FROM titles, sales
WHERE titles.title_id = sales.title_id
and sales.ord_date = (SELECT MAX(sales.ord_date) FROM sales)
) set ytd_sales=ytd_sales+qty
WHERE titles.title_id = sales.title_id
and sales.ord_date = (SELECT MAX(sales.ord_date) FROM sales)
) set ytd_sales=ytd_sales+qty
set ytd_sales = (select titles.ytd_sales + sales.qty from titles,sales
where titles.title_id = sales.title_id
AND sales.ord_date = (SELECT MAX(sales.ord_date) FROM sales)
SET ytd_sales = titles.ytd_sales + sales.qty
FROM titles, sales
WHERE titles.title_id = sales.title_id
SET ytd_sales = a.ytd_sales + (select b.qty from sales where b.title_id = a.title_id)
WHERE exists (select 1 from sales where b.title_id = a.title_id );
SET ytd_sales = a.ytd_sales + (select b.qty from sales b where b.title_id = a.title_id)
WHERE exists (select 1 from sales b where b.title_id = a.title_id );
set a.ytd_sales=(select a.ytd_sales+b.qty from sales b
where a.title_id=b.title_id)
where exists (select 1 from sales b
where a.title_id=b.title_id)
set column=(select ... from ... where...)
set ytd_sales=ytd_sales+
nvl((select qty from sales b where a.title_id=b.title_id),a.title_id)
UPDATE a
SET a.ytd_sales = a.ytd_sales + b.qty
FROM titles a, sales b
WHERE a.title_id = b.title_id
如果B表是一个导出表怎么办:
如:
UPDATE titles
SET ytd_sales = titles.ytd_sales + b.qty
FROM titles a, (select title_id,sales_id,sum(qty) from table_tmp group by title_id,sales_id) b
WHERE titles.title_id = b.title_id
怎么转换成oracle语法?
UPDATE titles
SET ytd_sales = titles.ytd_sales + b.qty
FROM titles a, (select title_id,sales_id,sum(qty) as qty from table_tmp group by title_id,sales_id) b
WHERE titles.title_id = b.title_id
Update titles a
set ytd_sales=ytd_sales+
nvl((select qty from sales b where a.title_id=b.title_id),0)