在sql中乘以正数和负数 [英] Multiply positive and negative number in sql

查看:687
本文介绍了在sql中乘以正数和负数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在SQL中总结一些正数和正数。但是这样做我会收到错误。



表达式:

(总和(-0.112,@ Transaction1 * 0.234,@ Transaction2 *( -0.88))



我可以获得这方面的帮助吗?

解决方案

  SELECT  -0。 112  +  0  234  *  @Transaction1   -   0  88  *  @Transaction2   As  Computed 



但我不确定这是你要搜索的内容。


Sum函数是一个列聚合。表示您输入一组数据的一个列名。



您可以使用'+'添加它们,创建临时表或cte,或使用数据透视表方法取决于你需要总和多少数据

I am trying to sum nehative and positive numbers in SQL. But I am getting error when doing so.

Expression:
(sum(-0.112, @Transaction1*0.234, @Transaction2 *(-0.88))

Can I get help on this please?

解决方案

SELECT -0.112 + 0.234 * @Transaction1 - 0.88 * @Transaction2 As Computed


But I'm not really sure this is what you are searching for.


The Sum function is a column aggregate. That means that you enter one column name of a set of data.

You can add them with the '+', create a temp table or cte, or use a pivot method depending on how much data you need to sum


这篇关于在sql中乘以正数和负数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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