将同一表的两列相乘并将结果存储到同一表的第三列 [英] Multiplying two columns of same table and storing result to the third column of same table

查看:85
本文介绍了将同一表的两列相乘并将结果存储到同一表的第三列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张桌子

SALES(sno,comp_name,quantity,costperunit,totalcost)

提供costperunit 值后,totalcost 需要计算为"totalcost=quantity*costperunit".

After supplying the costperunit values, totalcost need to be calculated as "totalcost=quantity*costperunit".

我想将 'quantity''costperunit' 列相乘,并将结果存储在同一个表的 'totalcost' 列中.

I want to multiply 'quantity' and 'costperunit' columns and store the result in 'totalcost' column of same table.

我已经试过了:

insert into SALES(totalcost) select quantity*costperunit as res from SALES

但是失败了!

有人请帮助我实现这一目标..提前致谢

Somebody please help me in achieving this.. Thanks in Advance

推荐答案

尝试更新表格

UPDATE SALES SET totalcost=quantity*costperunit

这篇关于将同一表的两列相乘并将结果存储到同一表的第三列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆