首页 > 解决方案 > Redshift - 将两个不同查询的输出相加到一个查询中

问题描述

我正在尝试对 Redshift 中 2 个不同 sql 的输出求和。

SQL1:

select count (*) from table1; -- Output : 10

SQL2:

select count (*) from table2; -- Output : 14

我正在尝试构建一个查询来显示这两个查询的总数。Expected output : 24

标签: amazon-redshift

解决方案


想出了解决办法:

select ((select count(*) from table1) +
       (select count(*) from table2)) as count

推荐阅读