开发者

Join two counts in sql query

开发者 https://www.devze.com 2023-02-04 10:02 出处:网络
Is it possible to have the sum of next two queries in one query? select COUNT(1) from BinaryAssets.BinaryAssetsTags

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

精彩评论

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