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'
精彩评论