SQL 求和语句 这两句的查询结果的和,用一句SQL语句表示应该怎么写?
Stringyszb21="SelectDuemoneyfrombusibudgetwherebkid=21";Stringyszb22="SelectDuemoneyf...
String yszb21="Select Duemoney from busibudget where bkid=21"; String yszb22="Select Duemoney from busibudget where bkid=22"; String 结果和=?
展开
2个回答
展开全部
select
sum(case
type
when
1
then
money
else
-money
end)
as
summoney
from
tablename
建议把type修改为type=1
为正
type=-1为负,则sql语句就:
select
sum(type*money)
from
tablename
sum(case
type
when
1
then
money
else
-money
end)
as
summoney
from
tablename
建议把type修改为type=1
为正
type=-1为负,则sql语句就:
select
sum(type*money)
from
tablename
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询