开发者

Join two counts in sql query

Is it possible to have the sum of next two queries in one query?

select COUNT(1) 
from BinaryAssets.BinaryAssetsTags
where TagId = 1731

select COUNT(1) 
from Planning.ScheduleTag
where TagId = 1731

Result from first query is 3 for example, from the 开发者_如何学编程second 2. I want one query that gives me back 5.


SELECT 
(select COUNT(1) from BinaryAssets.BinaryAssetsTags where TagId = 1731) 
+ 
(select COUNT(1) from Planning.ScheduleTag where TagId = 1731) 
AS total_sum


You can follow this syntax ,

select (select Count(1) from a)+(select Count(1) from b) as 'Total Count'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜