Related Tags:
SQL SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database. According to ANSI (American National Standards Institute), it is the standard language for relational database management systems. Learn More, SQL Server Management Studio (SSMS) SQL Server Management Studio (SSMS) is a software application first launched with Microsoft SQL Server 2005 that is used for configuring, managing, and administering all components within Microsoft SQL Server. Learn More, MSSQL Microsoft SQL Server is a relational database management system, or RDBMS, that supports a wide variety of transaction processing, business intelligence and analytics applications in corporate IT environments. It's one of the three market-leading database technologies, along with Oracle Database and IBM's DB2. Learn More,

Combine the summation of row counts from multiple tables and returned as one value in MSSQL

Description:I want to return one value which will be the sum of multiple row counts from different tables.

Posted by: | Posted on: Sep 13, 2018

1 answers

Replies

4

You can use a similar query as shown below which will combine/ take sum of the counts of three different tables on different conditions and returned as one value

SELECT
(SELECT COUNT(*)  from Table1 where Id=123)
+
(SELECT COUNT(*)  from Table2 where Id=321)
+
(SELECT COUNT(*)  from Table3 where Id=213)

Replied by: | Replied on: Sep 14, 2018



Reply
×

Code block Hyperlink bold Quotes block Upload Images

Preview