你这个相当于是下列语句:
select count(*) from (select id from table1) a,(select id from table2) b
where 条件 group by a.id,b.id
所以会是6272条
你可以改成如下:
select a.num,b.num from
(select count(id) num from table1 group by id)a
(select count(id) num from table2 group by id)b
select
a. col1, b.col2
from
(select count(id) as col1 from table1) as a,
(select count(id) as col2 from table2) as b
-------------这样写。
目前情况是迪笛卡尔积 结果是897乘以8,a,b 表的关联条件。
select a.AAA,b.BBB from
(select count(*) as AAA from 要查的表A where THETIME<=to_date('2018-03-07 13:58:36','yyyy-mm-dd hh24:mi:ss')) a,
(select count(*) as BBB from 要查的表B where THETIME<=to_date('2018-03-07 13:58:36','yyyy-mm-dd hh24:mi:ss')) b;
两张表的关联字段是什麽?没有关联字段才会出现6272
把关联字段条件加上再看看