2
我在SQL Server中有下列名为table1的表。减去两行
id value
1 10
2 100
3 20
4 40
5 50
当我执行查询以下查询它给我造成的110预计
SELECT SUM(value) from table1 where id in (1,2)
我要的是SUM相反意味着输出应该是90或-90。
我知道这可以通过写下面的查询
select ((SELECT value from table1 where id in (1)) - (SELECT value from table1 where id in (2)))
做,但没有任何简单的方式来做到这一点(类似SUM函数)。
这不是我想要的..我做了我的计算,但这是最接近的,所以我接受这个答案.. thx – Dhaval