如何将值添加到从其他表计算的表中 [英] how to add values to a table which is calculated from other table
本文介绍了如何将值添加到从其他表计算的表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在表 transac(scriptname,accnum,sharesbought,sharesold)中将值插入名为
。 sales(scriptname,accnum,remainingshares)
的表中
我想计算 remainingshares = sharesbough - sharesold
。
我可以通过以下查询执行此操作吗?
I need to insert value into table called sales (scriptname,accnum,remainingshares)
from table transac (scriptname,accnum,sharesbought,sharesold)
.
I want to calculate remainingshares = sharesbough - sharesold
.
Can I do this by the following query??
INSERT INTO sales(accnum, scriptname, remainingshares)
select accnum,scriptname,sharesbought-sharesold
from transac
推荐答案
尝试设置列别名:
(sharesbough - sharesold)as remainingshares。
Try to set a column alias:
(sharesbough - sharesold) as remainingshares.
这篇关于如何将值添加到从其他表计算的表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文