0

想象一下:t1 = 1 t2 = 3 t3 = 5

我需要在每个表上运行单独的选择,并以单个数量报告计数,即:

 select * 
   from (select count(*) from t1)
          + (select count(*) from t2)
          + (select count(*) from t3);

我的最终结果应该是 = 9

4

2 回答 2

3

你很接近; 你可以写:

 select (select count(*) from t1)
        + (select count(*) from t2)
        + (select count(*) from t3)
 ;
于 2012-09-20T15:41:13.773 回答
1
select 
    (select count(*) from t1)
    + (select count(*) from t2)
    + (select count(*) from t3);
于 2012-09-20T15:43:32.700 回答