你可以帮我解决如何将列A数据插入col3的空位。
查看附件。
CollectionChanged
欲望输出
ObservableCollection<T>
这称为可交换和。
答案 0 :(得分:1)
1。它适用于同一张桌子。
更新TABLENAME设置col3 = col2
** 2. **用于将一个表列数据插入另一个表
插入tab1(col1) 从tab2中选择col1
答案 1 :(得分:0)
试试这个:
Update tab1
set Col3=tab2.ColA
from tab1
inner join tab2 on tab1.col1=tab2.colB
答案 2 :(得分:0)
据我所知,你想要第二列的累积总和:
with toupdate as (
select t1.*,
sum(t1.col2) over (order by ??) as cume_col2
from tab1 t1
)
update toupdate
set col3 = cume_col2;
为了进行累积求和,您需要一个指定总和顺序的列。您显示的数据没有合适的列。
编辑:
哦,我明白了。排序来自第二个表:
with toupdate as (
select t1.*,
sum(t1.col2) over (order by t2.cola) as cume_col2
from tab1 t1 join
tab2 t2
on t1.col1 = t2.colb
)
update tab1
set col3 = toupdate.cume_col2
from tab1 join
toupdate
on tab1.col1 = toupdate.col1;