我正在尝试将值插入表中,但是当我这样做时,值不会进入我预期它们位于表底部的列。请看图像..我想要它在空白列
INSERT INTO storiacloud.schl_storia_school_status_try
(no_of_orders)
select count(otc_order_number)
from storiacloud.vw_storia_oms_orders as a
inner join
storiacloud.schl_storia_school_status_try as b
on a.school_ucn = b.ucn
group by school_ucn;
我也试过更新......但它给了我一个语法错误错误:语法错误在或附近"更新" 位置:188
更新t ^ 请帮忙
;With tbl as
(
Select Count(1) as cnt, b.ucn
FROM
storiacloud.schl_storia_school_status_try b
INNER JOIN
storiacloud.vw_storia_oms_orders a ON a.school_ucn = b.ucn
Group By school_ucn
)
update t
SET no_of_orders = tbl.Cnt
From tbl
join storiacloud.schl_storia_school_status_try as t on t.ucn = tbl.ucn
的图像
答案 0 :(得分:0)
希望这就是你要找的东西。 此代码解析正常,但不是测试
;With tbl as
(
Select Count(1) as cnt, b.ucn
FROM
storiacloud.schl_storia_school_status_try b
INNER JOIN
storiacloud.vw_storia_oms_orders a ON a.school_ucn = b.ucn
Group By school_ucn
)
update t
SET no_of_orders = tbl.Cnt
From tbl
join storiacloud.schl_storia_school_status_try as t on t.ucn = tbl.ucn