怎么查询sql表两列相加的和
下面这个表,我想查两列的值SELECTname,chinese,maths,chinese+mathsassumingFROM[User]是这样写的,逻辑上应该是得出20...
下面这个表,我想查两列的值SELECT name,chinese,maths,chinese + maths as suming FROM [User]是这样写的,逻辑上应该是得出20,40.。。。。但最后查出来值变成1010,2020。。。。比没有执行加法操作啊 怎么写啊
展开
展开全部
做个简单的。
两个数据表db1,db2
查询结果A是从数据表db1获取的:
select names, sale from db1
查询结果B是从数据表db2获取的:
select names, sale from db2
则查询结果C:
select names,sum(sale) as sale
from
(select names, sale from db1
union
select names, sale from db2
)
group by names
两个数据表db1,db2
查询结果A是从数据表db1获取的:
select names, sale from db1
查询结果B是从数据表db2获取的:
select names, sale from db2
则查询结果C:
select names,sum(sale) as sale
from
(select names, sale from db1
union
select names, sale from db2
)
group by names
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询