我需要有关SQL计算的帮助 [英] i need help with sql calculations

查看:87
本文介绍了我需要有关SQL计算的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.自从我使用sql以来已经有很长时间了.目前,我正在寻找一条选择语句,该语句将计算同一表(项目)中两列(价格,折扣)的值,但是我希望将结果存储在列折扣价的不同表(购买)中.一个例子会有所帮助.谢谢

解决方案

以下是查询所需语法的简单示例:

 插入  INTO  dbo.Buy(DiscountPrice)
选择折扣*价格
 FROM  dbo.Items 



这将为Items表中的每一行在Buy表中插入一个新行.这可能不完全是您想要的.如果要更新Buy表中的现有行,则可能需要执行UPDATE语句而不是INSERT.


hi. its been a long time since i used sql . currently i am looking for a select statement that would calculate values of two columns(price, discount) in the same table(items) but i want the result to be stored at a different table(buy) on the column discount price. an example would help. thank you

解决方案

Here is a simple example of the syntax needed for your query:

INSERT INTO dbo.Buy(DiscountPrice)
SELECT Discount * Price
FROM dbo.Items



This will insert a new row into the Buy table for each row in the Items table. This may not be exactly what you are looking for. You might need to do an UPDATE statement instead of an INSERT if you are trying to update existing rows in the Buy table.


这篇关于我需要有关SQL计算的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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